Problem:
Suppose you had an array A of n elements, each of which is 0 or 1.
Let us define a function f(k,A) which returns another array B, the result of sorting the first k elements of A in non-decreasing order. For example, f(4,[0,1,1,0,0,1,0])=[0,0,1,1,0,1,0]. Note that the first 4 elements were sorted.
Now consider the arrays B1,B2,…,Bn generated by f(1,A),f(2,A),…,f(n,A). Let C be the array obtained by taking the element-wise sum of B1,B2,…,Bn.
For example, let A=[0,1,0,1]. Then we have B1=[0,1,0,1], B2=[0,1,0,1], B3=[0,0,1,1], B4=[0,0,1,1]. Then C=B1+B2+B3+B4=[0,1,0,1]+[0,1,0,1]+[0,0,1,1]+[0,0,1,1]=[0,2,2,4].
You are given C. Determine a binary array A that would give C when processed as above. It is guaranteed that an array A exists for given C in the input.
Input Format:
The first line contains a single integer t (1≤t≤1000) — the number of test cases.
Each test case has two lines. The first line contains a single integer n (1≤n≤2⋅105).
The second line contains n integers c1,c2,…,cn (0≤ci≤n). It is guaranteed that a valid array A exists for the given C.
The sum of n over all test cases does not exceed 2⋅105.
Output Format:
For each test case, output a single line containing n integers a1,a2,…,an (ai is 0 or 1). If there are multiple answers, you may output any of them.
Note:
Here's the explanation for the first test case. Given that A=[1,1,0,1], we can construct each Bi:
- B1=[1,1,0,1];
- B2=[1,1,0,1];
- B3=[0,1,1,1];
- B4=[0,1,1,1]