#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 10;
int a[N], c[N];
#define lson rt << 1, l,
#define rson rt << 1 | 1, mid + 1,
#define ls rt << 1
#define rs rt << 1 | 1
int len, q, tree[N << 2], lazy[N << 2];
namespace SegmentTree{
const int N = 1e5 + 10;
inline void push_up(int rt) { tree[rt] = tree[ls] + tree[rs]; }
inline void push_down(int rt, int m){
if(!lazy[rt]) return;
lazy[ls] += lazy[rt], lazy[rs] += lazy[rt];
tree[ls] += lazy[rt] * (m - (m >> 1));
tree[rs] += lazy[rt] * (m >> 1);
lazy[rt] = 0;
}
static void build(int rt, int l, int r){
tree[rt] = lazy[rt] = 0;
if(l == r){
tree[rt] = c[l];
return;
}
int mid = l + r >> 1;
build(lson), build(rson);
push_up(rt);
}
static void update_part(int rt, int l, int r, int L, int R, int val){
if(l >= L && r <= R){
lazy[rt] += val, tree[rt] += (r - l + 1) * val;
return;
}
int mid = l + r >> 1;
push_down(rt, r - l + 1);
if(mid >= L) update_part(lson, L, R, val);
if(mid < R) update_part(rson, L, R, val);
push_up(rt);
}
static void update_point(int rt, int l, int r, int pos, int val){
if(l == r){
tree[rt] += val;
return;
}
int mid = l + r >> 1;
if(mid >= pos) update_point(lson, pos, val);
else update_point(rson, pos, val);
push_up(rt);
}
static int query(int rt, int l, int r, int L, int R){
if(l >= L && r <= R) return tree[rt];
int mid = l + r >> 1, ans = 0;
push_down(rt, r - l + 1);
if(mid >= L) ans += query(lson, L, R);
if(mid < R) ans += query(rson, L, R);
return ans;
}
}
inline void solve(){
int n = 0, sum = 0; cin >> n;
memset(a, 0, (n + 10) * sizeof(int));
for(int i = 1; i <= n; i++) cin >> c[i], sum += c[i];
int cnt1 = sum / n; SegmentTree::build(1, 1, n);
for(int i = n; i >= 1; i--){
if(SegmentTree::query(1, 1, n, i, i) >= i){
a[i] = 1;
SegmentTree::update_part(1, 1, n, i - cnt1 + 1, i, -1);
cnt1--;
}
}
for(int i = 1; i <= n; i++) cout << a[i] << " \n"[i == n];
}
signed main(){
int t = 0; cin >> t;
while(t--) solve();
return 0;
}