Royal Guard Problem

1

1 votes
Medium
Problem

Wakanda is a peace-loving country. But sometimes, other tribes do attack Wakanda. But the Wakandan Royal Guards are not to be trifled with. The Wakandan Royal Guards are brave and strong but lacks order according to their commander, Okoye. If a platoon consists of n soldiers, all of them have different rank (from 1 - lowest to n - highest) and at the time of war, they should be lined up from left to right in increasing order of rank. 
She discovered that her elite warriors preferred to do the fighting and leave the thinking to their superiors. So, when at the first call the royal guards lined up in fairly random order it was not because of their lack of discipline, but simply because they couldn't work out how to form a line in the correct order of ranks. Okoye was not at all amused, particularly as she soon found that none of the guards even remembered her own rank. Over the years of service for Wakanda, every guard had only learned which of the other soldiers were her superiors. But Okoya was not ready to give up easily when faced with a true military challenge. After a moment's thought, a solution of brilliant simplicity struck her and she issued the following order: "guards, starting from the left, one by one,

do: (step forward; go left until there is no superior to the left of you; get back in line).".

This did indeed get the guards sorted in a few minutes. The problem was solved... for the time being.


The next day, the guards came in exactly the same order as the day before and had to be rearranged using the same method. History repeated. After some weeks, Okoya managed to force each of her guards to remember how many guards she passed when going left, and thus make the sorting process even faster. 
If you know how many positions each guard has to walk to the left, can you try to find out what order of ranks the guards initially line up in? 

Input
The first line of input contains an integer T, the number of test cases. It is followed by T test cases, each consisting of 2 lines. The first line contains a single integer N. The second line contains N space separated integers wi, denoting how far the i-th soldier in line must walk to the left when applying Okoya algorithm. 

Output
For each test case, output a single line consisting of n space separated integers - the ranks of the guards, given from left to right in their initial arrangement.

Constraints

  • T < 50
  • 1 < N < 2X105
Time Limit: 10
Memory Limit: 256
Source Limit:
Editor Image

?