First, you should clear adjacency lists between test cases
Also, you might get WA on top of that, because on line 67 you should include 100
Mine gives TLE too. Sub-tasks passed, but TLE for the second task.
Use fast I/O (and get rid of
It Worked! Thanks!
thanks a lot, you are very helpful, great to have you support here. AC.