{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\nLittle Sub has another friend called lqybzx. One day, they are playing an interesting game.\r\n\u003c/p\u003e\r\n\u003cp\u003e\r\nIn this game, there is a variable called \"Justic Oops Heltion Attacks Neets Number\" which is written as \"JOHANN\". \r\n\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nInitially, JOHANN is equal to $0$. $N$ pairs of numbers ($x_i,y_i$) are given to Little Sub while $M$ pairs ($x\u0027_i,y\u0027_i$) are given to lqybzx. \n\u003c/p\u003e\n\u003cp\u003e\nFirstly, for every pair ($x_i,y_i$), Little Sub will choose either $x_i$ or $y_i$. Suppose he choose $k$, JOHANN will be changed to (JOHANN $\\oplus \\ k$). ($\\oplus$ denotes bitwise exclusive or)\n\u003c/p\u003e\n\u003cp\u003e\nAfter Little Sub\u0027s $N$ operations, lqybzx will do the same with his $M$ pairs. \n\u003c/p\u003e\n\n\u003cp\u003e\nThey know about each other\u0027s pairs from the beginning. \r\n\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nLittle Sub wishes the final value of JOHANN to be as great as possible while lqybzx wishes it to be as small as possible.\r\n\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nLittle Sub and lqybzx are very clever boys and they will choose the best strategy. Can you predict the final value of JOHANN?\r\n\u003c/p\u003e\r\n\r\n\u003ch4\u003eInput\u003c/h4\u003e\r\n\u003cp\u003e\nThere are multiple test cases. The first line of the input contains an integer $T$ ($1 \\le T \\le 20$), indicating the number of test cases. For each test case:\n\u003c/p\u003e\r\n\u003cp\u003e\r\nThe first line contains two integers $N$ and $M$ ($1 \\leq N,M \\leq 10000$).\r\n\u003c/p\u003e\r\n\u003cp\u003e\r\nThen $N$ lines follow. In each line, there are two integers $x_i,y_i$ ($1 \\leq x_i,y_i \\leq 10^{18}$), representing Little Sub\u0027s pairs. \r\n\u003c/p\u003e\r\n\u003cp\u003e\r\nThen $M$ lines follow. In each line, there are two integers $x\u0027_i,y\u0027_i$ ($1 \\leq x\u0027_i,y\u0027_i \\leq 10^{18}$), representing lqybzx\u0027s pairs. \r\n\u003c/p\u003e\r\n\r\n\u003ch4\u003e Output\u003c/h4\u003e\r\n\u003cp\u003e\r\nFor each test case, you should output a single integer in a line as your answer.\r\n\u003c/p\u003e\r\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\r\n2\r\n1 1\r\n6 3\r\n4 1\r\n2 2\r\n1 3\r\n4 6\r\n5 4\r\n2 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\r\n2\r\n2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\r\n\u003ch4\u003e Note \u003c/h4\u003e\r\n\u003cp\u003e\r\nIn the first sample, if Little Sub chooses $6$, lqybzx will choose $4$ and the result will be $2$.\n\u003c/p\u003e\n\u003cp\u003e\r\nIf Little Sub chooses $3$, lqybzx will choose $1$ and the result will also be $2$.\r\n\u003c/p\u003e\n\u003cp\u003e\nTherefore the answer is $2$.\n\u003c/p\u003e"}}]}