Medium

45.83%

Given a Binary tree, the problem is to find mirror of a given node. The mirror of a node is a node which exist at the mirror position of node in opposite subtree at the root.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the number of edges. Then next line contains the edges of the tree. The last line contains the target node of which mirror is to be found out.

**Output:**

Print the mirror node of the target node and if doesn't exist print -1.

**Constraints:**

1<=T<=100

1<=n<=100

1<=data of node<=100

1<=target<=100

**Example:
Input:**

2

8

1 2 L 2 4 L 4 7 R 1 3 R 3 5 L 3 6 R 5 8 L 5 9 R

4

8

1 2 L 2 4 L 4 7 R 1 3 R 3 5 L 3 6 R 5 8 L 5 9 R

7

**Output:**

6

-1