Given a snake and ladder board of order 5x6 , find the minimum number of dice throws required to reach the destination or last cell (30th cell) from source (1st cell) .
â€‹For the above board output will be 3
For 1st throw get a 2
For 2nd throw get a 6
For 3rd throw get a 2
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two lines. The first line of input contains an integer N denoting the no of ladders and snakes present. Then in the next line are 2*N space separated values a,b which denotes a ladder or a snake at position 'a' which takes to a position 'b'.
For each test case in a new line print the required answer denoting the min no of dice throws.
11 26 3 22 5 8 20 29 27 1 21 9