Help Needed in CHEFRRUN

Can someone help me with this problem? (Problem link below)

I tried to do it by applying Kosaraju’s Algorithm, but its showing WA in many TC’s
My Code link:-
https://www.codechef.com/viewsolution/49436993