
The first line contains ‘T,’ denoting the number of test cases.
The first line of the test case contains a single integer ‘N’ denoting the size of the ‘NUMS’ array.
The following N - 1 lines contain two space-separated integers denoting the i-th element of ARR[i].
For each test case, print a single line containing 'N' space-separated integers denoting any possible answer array elements.
The output of each test case will be printed in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= ’T’ <= 10
1 <= ‘N’<= 5000
1 <= ARR[i][0], ARR[i][1] <= 10 ^ 6
Where ‘i’ varies from 1 to ‘N’ - 1 and ‘N’ is the length of the array ‘nums’.
Time Limit: 1 sec.
The main idea is first create edges between adjacent nodes and then do the dfs traversal from the vertex with inDegree 1 as the vertex with inDegree 1 means it has only one adjacent element to it in nums array so it must be present at the first position since the element at the first position has only one element adjacent to it.