


1. There is no cycle present in a tree.
2. All values in the tree are unique.
3. Both nodes will always exist in the tree.
The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows.
The first line of each test case contains elements of a tree in level order form separated by space.
Order is:
ROOT_DATA, 'N' (Number of children of the root), 'N' children, and so on for every element
The second line of each test case contains two space-separated integers 'N1' and 'N2'.
For example, the input for the tree depicted in the below image would be :

Level 1 :
The root node of the tree is 20
Level 2 :
1st child of 20 = 10
2nd child of 20 = 35
Level 3 :
1st child of 10 = 5
2nd child of 10 = 15
1st child of 35 = 30
2nd child of 35 = 42
Level 4 :
Children of 5 = 0
Ist child of 15 = 13
Children of 30 = 0
Children of 42 = 0
Level 5 :
Children of 13 = 0
The input ends when all nodes at the last level have 0 children.
Note:
A tree node may have zero or more child nodes.
The above format was just to provide clarity on how the input is formed for a given tree.
The sequence will be put together in a single line separated by a single space. Hence, for the above-depicted tree, the input will be given as:
20 2 10 35 2 5 15 2 30 42 0 1 13 0 0 0
For each test case, print the shortest path from 'N1' to 'N2' in a single line.
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^2
1 <= N <= 25 * 10^2
1 <= NODE_DATA <= 10^5
1 <= N1, N2<= 10^5
Time Limit: 1 second
Consider function FINDPATH that takes ROOT node, node N1 and node N2 as parameter and:
We define function HASPATH that accepts tree node ROOT, array list of integers PATH and integer X as parameters and:
We define function PRINTPATH that accepts array list of integers PATH1 and PATH2 as parameters and:
Consider function FINDPATH that takes ROOT node, node N1 and node N2 as parameters and:
We define function HASPATH that accepts tree node ROOT, array list of integers PATH and integer X as parameters and:
We define function PRINTPATH that accepts array list of integers PATH1 and PATH2 as parameters and:
We define function FINDLCA that takes ROOT node, node N1 and node N2 as parameters and: