MOZSATLA - Sharmeen and the Lost Array

 

MOZSATLA - Sharmeen and the Lost Array

no tags 

Sharmeen loves array very much. Many days ago she wrote an array ( of n elements and the index of this array is 1 based ) in her notebook, but unfortunately she lost the notebook. She want to restore the array. The only clue she know that is if in any position(i) of the array (1<= i < n ), the element in this position is greater than, equal or less than the next position(i+1) element.

            Can you help her to restore the array?

Input

In the first line given an integer t ( 1 <= t <= 100 ), which is the number of test cases.

For each test case,

In the first line there will be given a positive integer n ( 1 <= n <= 10^5 ) which is the size of the lost array. In the next line there will be n - 1 intergers Xi( 0 <= Xi <= 2 ).

If, Xi = 0 , then ith  element is equal to (i+1)th element of the lost array.

If, Xi = 1 , then ith  element is less than (i+1)th element of the lost array.

If, Xi = 2 , then ith  element is greater than (i+1)th element of the lost array.

Output

For each test case you have to output the lost array in one line. If multiple solution exist then you have to print the lexicographically smallest one. Elements of the lost array must be greater than zero( 0 ).

For better understanding see the sample input output.





Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings