VPATH solution partial submission, WA for second testcase help

Help me, this solution for the VPATH problem passes first test case i.e partial score but WA for second
https://www.codechef.com/viewsolution/46422339

Please help