Medium Accuracy: 39.23% Submissions: 7042 Points: 4

Given two n-ary tree's the task is to check if they are mirror of each other or not.

Example

1 1
/ \ / \
2 3 3 2

Output: 1

1 1
/ \ / \
2 3 2 3

Output: 0

Note: you may assume that root of both the given tree as 1.

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. The first line of each test case contains two space separated values n and e denoting the no of nodes and edges respectively. Then in the next line two lines are 2*e space separated values u,v denoting an edge from u to v for the both trees .

Output:
For each test case in a new line print 1 if both the trees are mirrors of each other else print 0.