403379: GYM101147 E Jumping
Description
Shopping with the wife is one of men's hardest marriage responsibilities. Nour is a good husband. So he goes out with his wife every Friday to "Damasquino" mall.
Damasquino is a very famous mall in Damascus. It has a very unique transportation method between shops. Since the shops in the mall are laying in a straight line, you can jump on a very advanced trampoline from the shop i, and land in shop (i + di) or (i - di) depending on the direction of the jump. Where di is a constant given for each shop. You can jump forward or backward only, and you can't land any where before the first shop or after the last shop in the mall.
There are N shops in the mall, numbered from 1 to N. Nour's wife starts her shopping journey from shop 1 and ends it in shop N. Unfortunately, Nour sometimes gets lost from his wife (the mall is very crowded on Fridays). So he wants to know for each shop, what is the minimum number of trampoline jumps he has to make in order to reach shop N and see his wife again!
InputThe first line consists of one integer T, the number of test cases.
Each test case consists of two lines, the first line contains a single integer (2 ≤ N ≤ 105) the number of shops in the mall. The second line contains N integers. Where the ith integer (1 ≤ di ≤ N) is the constant described above for the ith shop.
OutputFor each test case, print N lines. The ith line should contain one integer, the minimum number of jumps needed to be made in order to reach shop N starting from shop i, or - 1 if it is impossible.
ExampleInput2Output
5
1 1 1 1 1
5
2 2 2 2 2
4Note
3
2
1
0
2
-1
1
-1
0
Large I/O files. Please consider using fast input/output methods.