Problem E

Lining Up

Submit File

Input File

Output File

Time Limit

: line.exe | line.class

: line.in

: line.out

: 1 second


Problem Description

N people P1, P2, P3, ..., PN go to the cinema to watch Jackie Chan’s new movie, Rush Hour 3. There’s so many people want to watch the movie so the cinema is very crowded. To buy a ticket, first one should get an ID number from a ticket machine (everyone uses credit card at the weekend). After he has an ID number, he should immediately join the queue to buy the movie’s ticket.

Normally, the ticket machine will produce ID numbers in ascending order (first come, first serve). But unfortunately, on that day the ticket machine produced a random order of ID number. To solve this problem, the wise manager of the BowoCinema, TheWiseMarcadian decided that each people would be served (be able to buy the ticket) by the ID number which they got from the ticket machine, not by the queue arrangement.

Many people in the queue got bored of waiting. Each of them wanted to know how many people behind him who had smaller ID number. The manager called this the Waiting-Sequence.

For Example, let there be 4 persons in the queue whose ID numbers were 3 4 2 1 consecutively (the left most one would be the most front people’s ID number, while the right most would be the most behind one’s in the queue)

There were 2 persons behind the first one (ID = 3) who had smaller ID number (ID 2 and 1).

There were 2 persons behind the second one (ID = 4) who had smaller ID number (ID 2 and 1).

There was 1 person behind the third one (ID = 2) who had smaller ID number (ID 1).

There was no people behind the fourth one (ID = 1) who had smaller number ID.

Therefore, the Waiting-Sequence for queue arrangement “3 4 2 1” is “2 2 1 0”.

Supposed that you have the Waiting-Sequence, could you construct the queue arrangement from that sequence?


Input Speficication

The first line of input contains an integer T, the number of test cases follow

Each test case begins with an integer N (1 <= N <= 1000), the number of person(s) in the queue. The next line contains N integer(s) indicating the Waiting-Sequence from the most front to the most behind one in the queue.


Output Speficication

For each case, print in a single line the queue arrangement from the given Waiting-Sequence. Each number should be separated by a single space.



Sample Input

Output for Sample Input

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



BNPC-HS 2007 Final Round, Problem E -Lining Up