|
||||||||||
Encode the treeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 295 Accepted Submission(s): 71 Problem Description Given n labeled vertices, there are nn-2 different trees. The number is too large, but Wiskey want to use a way to encode the tree that make a unique sequence associated with the labeled tree. Follow this way: 1.Select the vertex u which degree is 1 and the labeled number is the minimum. Example, u = 4. 2.Select the neighbor v of u, exists the edge which u to v. Example, v = 1. 3.Delete the edge from the tree. Example, the edge of 1-4 will be deleting. 4.Repeat the first step, until only two vertices left. 5.We will get the sequence {u1, u2бн un-2} and {v1, v2бн vn-2}. Now, give you the v sequence, tell me the u sequence. Input First line will contain one integer mean how many cases will follow by. N represents the number of vertices, and the label start from 1. (3 <= N <= 100). The next N-2 numbers mean the v sequence. Output Output the u sequence in one line, separate by a blank space. Sample Input
Sample Output
Author Wiskey | ||||||||||
|