Write a program to print the pre order, in order and post order traversal of the given binary tree.
Write a program to print the pre order, in order and post order traversal of the given binary tree.
The first line will be an integer T (1≤T≤10), which is the number of test cases.
For each test data:
The first line contains one integer N (1≤N≤10^4) — the number of the nodes.
Each of the next N - 1 lines contain two integers a and b, which means node a is the father of node b (1≤a, b≤N). If a node has two sons, the son appeared earlier is the left son and another is the right son. If a node only has one son, the son is the left son.
For each test cases, print three lines: the pre order, in order and post order traversal of the given binary tree.
1
8
1 4
1 3
4 2
2 7
3 5
3 6
6 8
1 4 2 7 3 5 6 8
7 2 4 1 5 3 8 6
7 2 4 5 8 6 3 1