题库练习 We Need the Zero
← 上一题 下一题 →

A15823 | We Need the Zero

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). 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 < 2^8$ ).

输入格式

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 < 2^8$ ).

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

输出格式

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

输入输出样例

输入 #1
5
3
1 2 5
3
1 2 3
4
0 1 2 3
4
1 2 2 3
1
1
输出 #1
6
0
3
-1
1
C++ 编辑器
输入
输出