CF1805A.We Need the Zero

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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

输入格式

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

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

The second line of the test case contains nn integers — array aa ( 0ai<280 \le a_i < 2^8 ).

It is guaranteed that the sum of nn over all test cases does not exceed 10310^3 .

输出格式

For each set test case, print the integer xx ( 0x<280 \le x < 2^8 ) if it exists, or 1-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

说明/提示

In the first test case, after applying the operation with the number 66 the array bb becomes [7,4,3][7, 4, 3] , 743=07 \oplus 4 \oplus 3 = 0 .

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

首页