There are N chairs arranged around a circular table. Each chair has a number \(Num_i\) written on it. Any person sitting on a chair i can jump \(Num_i\) number of indices towards left or right, You are sitting on chair X and you have to reach chair Y. Tell the minimum number of jumps required by you. If its impossible to reach then print 1.
Example :- If your sitting on chair 4 and it has number 2 written on it then you can either jump to chair number 2 or chair number 6.
Constraints
\(1<=T<=100\)
\(1<=N<=10^4\)
\(1<=Num_i<=10^9\)
\(1<=X,Y<=N\)
Format of the input file:
First line : T i.e number of testcases.
For each testcase :
First line : Three space separated integers N , X and Y.
Second line : N space separated integers denoting the chNum.
Format of the output file:
For each testcase print the answer in a separate line.
For the given testcase we can jump from chair 1 to chair 3 and from chair 3 to chair 5 hence we can reach chair 5 in exactly 2 jumps.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor