One test case is failing in SNAKES AND LADDER game

This is my code but , i cannot get what could be the possible mistake in my code for snakes and ladder game.

Your code is not printing -1, instead its printing 1.
Try to debug as per your logic for the test -:
Test Case -:
10
2
5 66
9 88
1
67 8
1
3 90
7
99 10
97 20
98 30
96 40
95 50
94 60
93 70
2
5 66
9 88
1
67 8
1
3 90
7
99 10
97 20
98 30
96 40
95 50
94 60
93 70
2
5 66
9 88
1
67 8
1
3 90
7
99 10
97 20
98 30
96 40
95 50
94 60
93 70
2
5 66
9 88
1
67 8
1
3 90
7
99 10
97 20
98 30
96 40
95 50
94 60
93 70
2
5 66
9 88
1
67 8
1
3 90
7
99 10
97 20
98 30
96 40
95 50
94 60
93 70

Output should be -:
4
-1
4
-1
4
-1
4
-1
4
-1

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.