Problem C: Level traversal

Problem C: Level traversal

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 813  Solved: 234
[Submit][Status][Web Board]

Description

        There is an m-ary tree. You should find the level traversal order of this tree. The root node of the tree is 1. When you traverse child nodes with the same parent node, the traversal order of the child nodes should be in ascending order.


Input

In the first line, T are the number of the test (1<=T<=20).

In each case:

The first line have one integer N. N are the number of the nodes. (1<=N<=1e5).

The next line have N-1 integers {a1,a2...an-1}, which ai is the father of the i+1. (1<=ai<=N).


Output

Output is the order of the level traversal. When you traverse child nodes with the same parent node, the traversal order of the child nodes should be in ascending order.



Sample Input

2
4
1 1 1
5
1 1 3 2

Sample Output

1 2 3 4
1 2 3 5 4

HINT

[Submit][Status]