#P16742. [GKS 2019 #G] The Equation
[GKS 2019 #G] The Equation
Problem Description
The laws of the universe can be represented by an array of non-negative integers. The i-th of these integers is .
The universe is good if there is a non-negative integer such that the following equation is satisfied: $(A_1 \text{ xor } k) + (A_2 \text{ xor } k) + ... (A_N \text{ xor } k) \le M$, where xor denotes the bitwise exclusive or.
What is the largest value of for which the universe is good?
Input Format
The first line of the input gives the number of test cases, . test cases follow. Each test case begins with a line containing the two integers and , the number of integers in and the limit on the equation, respectively.
The second line contains integers, the i-th of which is , the i-th integer in the array.
Output Format
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the largest value of k for which the universe is good, or if there is no such .
4
3 27
8 2 4
4 45
30 0 4 11
1 0
100
6 2
5 5 1 5 1 0
Case #1: 12
Case #2: 14
Case #3: 100
Case #4: -1
Hint
In sample case #1, the array contains integers and . The largest possible value of that gives a good universe is ($(8 \text{ xor } 12) + (2 \text{ xor } 12) + (4 \text{ xor } 12) = 26$).
In sample case #2, the array contains integers and . The largest possible value of that gives a good universe is ($(30 \text{ xor } 14) + (0 \text{ xor } 14) + (4 \text{ xor } 14) + (11 \text{ xor } 14) = 45$).
In sample case #3, the array contains integer and . The largest possible value of that gives a good universe is ().
In sample case #4, there is no value of that gives a good universe, so the answer is .
Limits
.
.
Test set 1 (Visible)
.
, for all .
Test set 2 (Hidden)
.
, for all .