Everyone Loves Playing Games

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

One day, Acesrc and Roundgod are playing an interesting game called Important Choice Pairs of Cakes (ICPC).

In this game, there is a variable XX. Initially, XX is equal to 00. NN pairs of numbers (x_i,y_ix\_i,y\_i) are given to Acesrc while MM pairs (x_i,y_ix'\_i,y'\_i) are given to Roundgod. 

Firstly, for every pair (x_i,y_ix\_i,y\_i), Acesrc will choose either x_ix\_i or y_iy\_i. Suppose he choose kk, XX will be changed to (XX  k\oplus \ k). (\oplus denotes bitwise exclusive or)

After Acesrc's NN operations, Roundgod will do the same with his MM pairs. 

They know about each other's pairs from the beginning. Acesrc wishes the final value of XX to be as great as possible while Roundgod wishes it to be as small as possible.

Acesrc and Roundgod are very clever boys and they will choose the best strategy. Can you predict the final value of XX?

입력

There are multiple test cases. The first line of the input contains an integer TT (1T201 \le T \le 20), indicating the number of test cases. For each test case:

The first line contains two integers NN and MM (1N,M100001 \leq N,M \leq 10000).

Then NN lines follow. In each line, there are two integers x_i,y_ix\_i,y\_i (1x_i,y_i10181 \leq x\_i,y\_i \leq 10^{18}), representing Acesrc's pairs. 

Then MM lines follow. In each line, there are two integers x_i,y_ix'\_i,y'\_i (1x_i,y_i10181 \leq x'\_i,y'\_i \leq 10^{18}), representing Roundgod's pairs.

출력

For each test case, you should output a single integer in a line as your answer.

힌트

In the first sample, if Acesrc chooses 66, Roundgod will choose 44 and the result will be 22.

If Acesrc chooses 33, Roundgod will choose 11 and the result will also be 22.

Therefore the answer is 22.