/* *********************************************** Author :kuangbin Created Time :2015/12/5 19:08:43 File Name :F:\ACM\2015ACM\BestCoder\BC65\C.cpp ************************************************ */ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MAXN = 50010; int n; int c[MAXN]; int lowbit(int x) { return x&(-x); } int sum(int i) { int s = 0; while(i > 0) { s += c[i]; i -= lowbit(i); } return s; } void add(int i,int val) { while(i <= n) { c[i] += val; i += lowbit(i); } } int a[MAXN]; int b[MAXN]; int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T; scanf("%d",&T); while(T--) { scanf("%d",&n); b[0] = 0; for(int i = 1;i <= n;i++)scanf("%d",&b[i]); memset(c, 0, sizeof(c)); for(int i = 1;i <= n;i++)add(i,1); for(int i = n; i >= 1;i--) { int tmp = b[i] - b[i-1]; tmp = i-tmp; int l = 1, r = n; int ans = r; while(l <= r) { int mid = (l+r)/2; if(sum(mid) >= tmp) { ans = mid; r = mid-1; } else l = mid+1; } a[i] = ans; add(a[i],-1); } for(int i = 1;i <= n;i++) { printf("%d%c",a[i],i==n?'\n':' '); } } return 0; }