The Flight Plan In Hackerearh

I have sorted my adjacency list inspite it is showing wrong result for this case:-
5 5 3 3
1 3
1 2
2 4
3 5
2 5
1 5

Have i done sorting wrong??
My code is here :-https://ide.codingblocks.com/s/149219

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.