#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <set>
#include <cstdio>
#include <string>
#include <stack>
#include <map>
#include <sstream>
#define ll long long
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()
using namespace std;
void AIA()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void file()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const ll OO = 1e18 + 7;
const long double PI = acos(-1);
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dx4[] = {0, 1, 0, -1};
int dy[] = {1, -1, 0, 0, 1, -1, -1, 1}, dy4[] = {1, 0, -1, 0};
int main()
{
// Verify Your thought before Coding.
AIA();
file();
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<ll> v(n + 1), dif(n + 1), suf(n + 2), tem(n + 1);
vector<pair<ll, ll>> sum(n + 1);
for (int i = 1; i <= n; i++)
cin >> v[i];
for (int i = 1; i <= n; i++)
{
sum[i].first = i + v[i];
sum[i].second = i;
}
sum[0].first = sum[0].second = -OO;
sort(all(sum));
suf[n + 1] = OO;
for (int i = n; i >= 1; i--)
{
suf[i] = min(suf[i + 1], sum[i].second);
tem[i] = sum[i].first;
}
tem[0] = -OO;
for (int i = 1; i <= n; i++)
{
auto lw = lower_bound(all(tem), i - v[i]);
if (lw == tem.end())
cout << -1 << " ";
else
cout << suf[lw - tem.begin()] << " ";
}
cout << "\n";
}
}
Copy