You are given an array A of n integers (1 based indexing). From any index i of this array we can move to the following indexes:
Now You have to answer Q queries, in each query, you are given a start index A and an end index B, you have to find the minimum number of attempts to reach from starting index A to the ending index B.
INPUT:
OUTPUT:
CONSTRAINTS:
1≤N≤1000
1≤Q≤106
1≤Ai≤109
1<=A,B<=n
For 2nd query, First condition is satisfied. hence only one attempt is required.