Help with TLE in PERCAPTA from COOK119

This is the problem, if you haven’t checked it out yet.

I am new to all these graph traversal problems, so any tips and tricks would be appreciated. thakyou.

here is my latest submission.