#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
#define PI(n) ((double)acos(n))
#define pw2(n) (1LL<<(n))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d%d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#else
// online submission
#endif
}
void fast()
{
std::ios_base::sync_with_stdio(0);
cin.tie(NULL); cout.tie(NULL);
}
#define pair1 pair<int,int>
int n;
int dp[100001][2];
int v[100001];
int vis[100000];
// 0 >> i+d 1 >> i-d
int calc(int node){
if (node == n)
return 0;
if (node > n || (node <= 0))
return 1e9;
if (dp[node][0] != -1 && dp[node][1] != -1){
return min(dp[node][0], dp[node][1]);
}
int mn = 1e9;
if (dp[node][0] == -1){
dp[node][0] = 1e9;
mn = min(mn, calc(node + v[node]) + 1);
}
if (dp[node][1] == -1){
dp[node][1] = mn;
mn = min(mn, calc(node - v[node]) + 1);
}
if (dp[node][1] != -1 && dp[node][0] != -1){
// min between i-d , i+d
mn = min(dp[node][1], mn);
mn = min(dp[node][0], mn);
dp[node][0] = dp[node][1] = mn;
}
return mn;
}
int main()
{
file();
//freopen("jumping.in", "r", stdin);
int t;
cin >> t;
while (t--){
sfi1(n);
for (int i = 1; i <= n; i++){
int a;
sfi1(a);
v[i] = a;
}
memset(dp, -1, sizeof dp);
vector<int>ans(n + 1);
for (int i = 1; i <= n; i++){
ans[i] = calc(i);
}
for (int i = 1; i <= n; i++){
if (ans[i] == 1e9) ans[i] = -1;
printf("%d\n", ans[i]);
}
}
}
I2RlZmluZSBfQ1JUX1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