Please have a look at this Graph Problem

problem link- Contest Page | CodeChef
my code: code1.txt - Google Drive
Dunno why this gives “wrong soln”. Please help

Use old threads if you have doubt