{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAmong Johnny\u0027s numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad\u0027s office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.\u003c/p\u003e\u003cp\u003eThere is a set $$$S$$$ containing very important numbers on his dad\u0027s desk. The minute Johnny heard about it, he decided that it\u0027s a good idea to choose a \u003cspan class\u003d\"tex-font-style-bf\"\u003epositive\u003c/span\u003e integer $$$k$$$ and replace each element $$$s$$$ of the set $$$S$$$ with $$$s \\oplus k$$$ ($$$\\oplus$$$ denotes the \u003ca href\u003d\"https://en.wikipedia.org/wiki/Exclusive_or#Computer_science\"\u003eexclusive or\u003c/a\u003e operation). \u003c/p\u003e\u003cp\u003eHelp him choose such $$$k$$$ that Johnny\u0027s dad will not see any difference after his son is done playing (i.e. Johnny will get the same set as before playing). It is possible that no such number exists. It is also possible that there are many of them. In such a case, output the smallest one. Note that the order of elements in a set doesn\u0027t matter, i.e. set $$$\\{1, 2, 3\\}$$$ equals to set $$$\\{2, 1, 3\\}$$$.\u003c/p\u003e\u003cp\u003eFormally, find the smallest positive integer $$$k$$$ such that $$$\\{s \\oplus k | s \\in S\\} \u003d S$$$ or report that there is no such number.\u003c/p\u003e\u003cp\u003eFor example, if $$$S \u003d \\{1, 3, 4\\}$$$ and $$$k \u003d 2$$$, new set will be equal to $$$\\{3, 1, 6\\}$$$. If $$$S \u003d \\{0, 1, 2, 3\\}$$$ and $$$k \u003d 1$$$, after playing set will stay the same.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eIn the first line of input, there is a single integer $$$t$$$ ($$$1 \\leq t \\leq 1024$$$), the number of test cases. In the next lines, $$$t$$$ test cases follow. Each of them consists of two lines. \u003c/p\u003e\u003cp\u003eIn the first line there is a single integer $$$n$$$ ($$$1 \\leq n \\leq 1024$$$) denoting the number of elements in set $$$S$$$. Second line consists of $$$n$$$ \u003cspan class\u003d\"tex-font-style-bf\"\u003edistinct\u003c/span\u003e integers $$$s_i$$$ ($$$0 \\leq s_i \u0026lt; 1024$$$), elements of $$$S$$$.\u003c/p\u003e\u003cp\u003eIt is guaranteed that the sum of $$$n$$$ over all test cases will not exceed $$$1024$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint $$$t$$$ lines; $$$i$$$-th line should contain the answer to the $$$i$$$-th test case, the minimal positive integer $$$k$$$ satisfying the conditions or $$$-1$$$ if no such $$$k$$$ exists.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e6\n4\n1 0 2 3\n6\n10 7 14 8 3 12\n2\n0 2\n3\n1 2 3\n6\n1 4 6 10 11 12\n2\n0 1023\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n4\n2\n-1\n-1\n1023\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, the answer is $$$1$$$ because it is a minimum positive integer and it satisfies all the conditions.\u003c/p\u003e"}}]}