#P1746C. Permutation Operations

    ID: 674 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 4 Uploaded By: Tags>constructive algorithmsgreedyimplementationmath*1300

Permutation Operations

Description

You are given a permutation aa of size nn and you should perform nn operations on it. In the ii-th operation, you can choose a non-empty suffix of aa and increase all of its elements by ii. How can we perform the operations to minimize the number of inversions in the final array?

Note that you can perform operations on the same suffix any number of times you want.

A permutation of size nn is an array of size nn such that each integer from 11 to nn occurs exactly once in this array. A suffix is several consecutive elements of an array that include the last element of the array. An inversion in an array aa is a pair of indices (i,j)(i, j) such that i>ji > j and ai<aja_{i} < a_{j}.

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1051 \le n \le 10^5) — the size of the array.

The second line contains nn distinct integers a1,a2,,ana_{1}, a_{2}, \dots, a_{n} (1ain1 \le a_i \le n), the initial permutation aa.

It's guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

For each test case, print nn integers x1,x2,,xnx_{1}, x_{2}, \ldots, x_{n} (1xin1 \le x_{i} \le n for each 1in1 \le i \le n) indicating that the ii-th operation must be applied to the suffix starting at index xix_{i}. If there are multiple answers, print any of them.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1051 \le n \le 10^5) — the size of the array.

The second line contains nn distinct integers a1,a2,,ana_{1}, a_{2}, \dots, a_{n} (1ain1 \le a_i \le n), the initial permutation aa.

It's guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, print nn integers x1,x2,,xnx_{1}, x_{2}, \ldots, x_{n} (1xin1 \le x_{i} \le n for each 1in1 \le i \le n) indicating that the ii-th operation must be applied to the suffix starting at index xix_{i}. If there are multiple answers, print any of them.

Sample Input 1

4
4
1 2 3 4
5
1 3 2 4 5
3
2 3 1
1
1

Sample Output 1

1 1 1 1
1 4 3 2 1
1 3 3
1

Note

In the first test case one of the optimal solutions is to increase the whole array on each operation (that is, choose the suffix starting at index 11). The final array [11,12,13,14][11, 12, 13, 14] contains 00 inversions.

In the second test case, aa will be equal to [2,4,3,5,6][2, 4, 3, 5, 6], [2,4,3,7,8][2, 4, 3, 7, 8], [2,4,6,10,11][2, 4, 6, 10, 11], [2,8,10,14,15][2, 8, 10, 14, 15] and [7,13,15,19,20][7, 13, 15, 19, 20] after the first, second, third, fourth, and fifth operations, respectively. So the final array aa has zero inversions.