SPOJ Graph Problem ( AKBAR ) : BFS

I was solving SPOJ Akbar problem. But getting WA. Can Anyone look into my code let me know which corner case I am missing. Any help will be appreciated. Thanks a lot.

Find Code at this link:

and Problem at this link: