It is 2500 and John lives in a city consisting of buildings numbered . The building numbered 1 is John’s school and building numbered is his home. All roads of the city are unidirectional and are given a label which denotes the road number. There exists different kinds of label. John wishes to reach his home from his school via some path by travelling on the unidirectional roads.
In a parallel mirror world consisting on buildings numbered and there exists a doppelganger of John whose name is Ron. In this parallel world, building is the school and is his home. Ron is controlled completely by John’s state of mind. Initially both are in school in their respective worlds. Now John starts travelling to his home in the real world. Whenever John takes a path with label from the building where he is at currently, Ron also takes the path with the same label from the building where he is at currently in the mirror world.
Now the condition is that whenever John reaches his home in the real world, only then Ron should also reach his home in the parallel world. Only then we can say it is a mirror world. For some building that they reach simultaneously, if one of them is able to take a path with label but the other isn't able to take the same, then it is not mirror world. Find if this a mirror world or not.
Note that the number of distinct labels are in both the worlds and there can be at most one path from each building for each label
INPUT FORMAT
First line contains an integer denoting the number of test cases.
first line of each test case contains an integer denoting the number of roads.
the next line contains 3 integers denoting the number of nodes, number of edges in the first graph and the node number of the home.
Next lines contain 3 integers denoting that Ron goes from to by road .
Next line contains 3 integers denoting the number of nodes, edges in the second graph, and the node number of the home in second world.
Next lines contain 3 integers denoting that Ron goes from to by road .
OUTPUT FORMAT
For each of the testcases output a or in a separate line according to the answer.
CONSTRAINTS
SUBTASKS (10 Points)
For the first graph he can reach home (i.e 3) from 1 using road number 2 and through 2 using road number 1 and then again road number 1.
However, in the second case, he can reach node 3 using node 1 by road 1. So this is not a mirror world. Also it is impossible to reach node 3 (i.e House) thorugh node 2, which is possible in the first world.
So, this is not a mirror world.