Snakes and ladder board

this is my code: https://ide.codingblocks.com/s/49630
sample output was correct but on submission showing wrong answer.

Hi Ishaan, for the question Snake and Ladders Board (BFS), your code is not giving the correct ans for the sample input. The sample input is:
1
30 4 4
3 22
5 8
11 26
20 29
17 4
19 7
21 9
27 1
The sample output is: 3
Your code’s output is: 14
The following is the input format:

First line contains integer t as number of test cases. Each test case contains following input. First line contains three integers n, l, s which represents the number of cell of board, number of ladders and number of snakes. Following l lines contains the description of ladders and next s lines contains description of snakes.

The input of your code is not according to the specified input format.