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.
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.
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 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.
2
4
1 1 1
5
1 1 3 2
1 2 3 4
1 2 3 5 4