Everything i did, I did it for me.
- Walter White, Breaking Bad
Walter always says he is doing everything for his family. But in reality, due to his ego, he became obsessed with making as much money as possible.
It turned out that his income would be equal to the maximal possible value of f((q1β,q2β,β¦,qnβ))+f((pq1ββ,pq2ββ,β¦,pqnββ)) over all permutations (q1β,q2β,β¦,qnβ) of integers from 1 to n.
Here p1β,p2β,β¦,pnβ is Walt's favorite permutation, and f(a) is defined as the number of positions 1β€iβ€n, for which aiβ=max(a1β,a2β,β¦,aiβ): in other words, the number of prefix maximums.
Find any permutation (q1β,q2β,β¦,qnβ) of integers from 1 to n that maximizes Walt's income. If there are many such permutations, find any of them.
The first line contains a single integer t (1β€tβ€105) - the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer n (1β€nβ€2β
105) - the length of Walt's favorite permutation.
The second line of each test case contains n integers p1β,p2β,β¦,pnβ (1β€piββ€n, all piβ are distinct) - elements of the permutation.
It is guaranteed that the sum of n over all test cases does not exceed 2β
105.
Output data
For each test case, output n integers q1β,q2β,β¦,qnβ (1β€qiββ€n, all qiβ are distinct) - any permutation of integers from 1 to n, which maximizes the value of f((q1β,q2β,β¦,qnβ))+f((pq1ββ,pq2ββ,β¦,pqnββ))
Example 1
stdin
3
3
1 2 3
4
2 4 3 1
5
1 5 2 4 3
stdout
1 2 3
1 3 4 2
1 3 5 4 2
Explanation
In the first test case, for q=(1,2,3), the value is f(1,2,3)+f(p1β,p2β,p3β)=f(1,2,3)+f(1,2,3)=3+3=6.
In the second test case, for q=(1,3,4,2), the value is f(1,3,4,2)+f(p1β,p3β,p4β,p2β)=f(1,3,4,2)+f(2,3,1,4)=3+3=6.
In the third test case, for q=(1,3,5,4,2), the value is f(1,3,5,4,2)+f(p1β,p3β,p5β,p4β,p2β)=f(1,3,5,4,2)+f(1,2,3,4,5)=3+5=8.