#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pb push_back
#define pp pop_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
ld pi=acos(-1);
ll mod=1e9+7;
void fast()
{
cin.sync_with_stdio(0) ;
cin.tie(0) ;
cout.tie(0);
}
bool cmp(pair<int,int>a,pair<int,int>b)
{
if(a.first==b.first)
return b.second>a.second;
return a.first<b.first;
}
long long gcd(long long a,long long b)
{
if(a==0)
return b;
return gcd(b%a,a);
}
long long fp(ll b, ll p)
{
ll ans = 1;
while (p)
{
if (p % 2)
{
ans = (ans * b)%mod;
}
b = (b * b)%mod;
p /= 2;
}
return ans%mod;
}
bool isp(long long n)
{
if(n==1)
return false;
if(n==2||n==3)
return true;
if(n%2==0||n%3==0)
return false;
for(long long i=5;i*i<=n;i+=2)
if(n%i==0)
return false;
return true;
}
long long fc(long long n)
{
if(n==0)
return 1;
long long s=1;
for(int i=1;i<=n;i++)
s=s*i;
return s;
}
ll lcm(ll a,ll b)
{
ll m=gcd(a,b);
m=a/m*b;
return m;
}
#define MAX 10000001
ll primes[MAX] ;
bool sieve[MAX] ;
int l;
void genPrimes()
{
primes[l++] = 2 ;
long long i,j ;
for(j=4;j<MAX;j+=2) sieve[j] = true ;
for(i=3;i<MAX;i+=2)
{
if(sieve[i]==false)
{
primes[l++] = i ;
for(j=i*i;j<MAX;j+=i) sieve[j] = true ;
}
}
}
void Nn(ll n)
{
map<int,int>mp;
int od=0,ev=0;
ll tmp = sqrt(n),i ;
ll j = 0 ;
ll p[1000];
memset(p,0,sizeof(p));
for(i=0;primes[i]<=tmp;i++)
if(n % primes[i] == 0)
{
int cnt = 0 ;
while(n % primes[i] == 0)
{
cnt ++ ;
//cout<<" "<<primes[i]<<"\n";
n /=primes[i] ;
}
if(cnt%2)
od++;
else
ev++;
p[j++]=primes[i] ;
mp[primes[i]]=cnt;
tmp = sqrt(n) ;
}
if(n>1) {
p[j++]=n;
od++;
// cout<<" "<<n<<"\n";
mp[n]++;
}
sort(p,p+j);
for(int i=0;i<j;i++)
cout<<p[i]<<'^'<<mp[p[i]]<<" ";
// sort(p,p+j);
}
/*ll c=1e9+7;
ll modd(ll a,ll b)
{
ll rs=0;
a=a%c;
while(b)
{
if(b%2)
rs=(rs+a)%c;
a=(2*a)%c;
b/=2;
}
return rs;
}*/
const int N = 1000001;
ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];
void InverseofNumber(ll p)
{
naturalNumInverse[0] = naturalNumInverse[1] = 1;
for (int i = 2; i <= N; i++)
naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
void InverseofFactorial(ll p)
{
factorialNumInverse[0] = factorialNumInverse[1] = 1;
for (int i = 2; i <= N; i++)
factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}
void factorial(ll p)
{
fact[0] = 1;
for (int i = 1; i <= N; i++) {
fact[i] = (fact[i - 1] * i) % p;
}
}
ll B(ll N, ll R, ll p)
{
ll ans = ((fact[N] * factorialNumInverse[R])
% p * factorialNumInverse[N - R])% p;
return ans;
}
ll k;
vector<ll>c;
void sol(ll p)
{
for(int i=0;i<=1e5;i++)
{
ll sm=0;
for(int j=0;j<=i/k;j++)
sm=(sm+B(i-j*(k-1),j,p))%p;
if(c.empty())
c.pb(sm);
else
c.pb((sm+c.back())%p);
}
}
ll sr(ll m,vector<ll>b,int l,int r)
{
int md=(l+r)/2;
if(b[md]>=m&&(md==0||b[md-1]<m))
return b[md];
else if(b[md]<m)
return sr(m,b,md+1,r);
}
int main() {
fast();
int tt=1;
cin>>tt;
for(int ts=1;ts<=tt;ts++)
{
int n,c;
cin>>n;
vector<ll>a,b;
map<ll,int>mp;
ll x;
for(int i=0;i<n;i++)
{
cin>>x;
a.pb(i+1-x);
if(mp[i+1+x]==0)
{
mp[i+1+x]=i+1;
}
if(b.empty())
{
b.pb(i+1+x);
c=i+1+x;
}
else
{
if(i+1+x>c)
{
b.pb(x+1+i);
c=i+1+x;
}
}
}
int k=b.size();
for(int i=0;i<n;i++)
{
ll m=a[i];
if(b[0]>=m)
cout<<"1 ";
else if(m>b[k-1])
cout<<"-1 ";
else
cout<<mp[sr(m,b,0,k-1)]<<" ";
}
cout<<"\n";
}
return 0;
}
Copy