Codeforces Round 862 (Div. 2)
A
We Need the Zero
Codeforces
800
原题
←B →
翻译中…

There is an array $a$ consisting of non-negative integers. You can choose an integer $x$ and denote $b_i=a_i \oplus x$ for all $1 \le i \le n$, where $\oplus$ denotes the bitwise XOR operation. Is it possible to choose such a number $x$ that the value of the expression $b_1 \oplus b_2 \oplus \ldots \oplus b_n$ equals $0$?

翻译中…

It can be shown that if a valid number $x$ exists, then there also exists $x$ such that ($0 \le x \lt 2^8$).

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.

翻译中…

The first line of the test case contains one integer $n$ ($1 \le n \le 10^3$) — the length of the array $a$.

翻译中…

The second line of the test case contains $n$ integers — array $a$ ($0 \le a_i \lt 2^8$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^3$.

翻译中…

Output

翻译中…

For each set test case, print the integer $x$ ($0 \le x \lt 2^8$) if it exists, or $-1$ otherwise.

翻译中…

Note

翻译中…

In the first test case, after applying the operation with the number $6$ the array $b$ becomes $[7, 4, 3]$, $7 \oplus 4 \oplus 3 = 0$.

翻译中…

There are other answers in the third test case, such as the number $0$.

翻译中…

样例

Input #1
5
3
1 2 5
3
1 2 3
4
0 1 2 3
4
1 2 2 3
1
1
Output #1
6
0
3
-1
1
InputCopy OutputCopy
题目信息
题号
1805A
时间限制
1 s
内存限制
256 MB
标签
位运算
暴力

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。