You are given a set \(S\) of distinct positive integers of size \(n\) (\(n\) is always even). Print the minimum positive integer \(k\) that is greater than 0 such that after replacing each element \(e\) of the set \(S\) with \(e⊕k\), set \(S\) remains the same.
Print -1 if there is no such \(k\).
Note: It is guaranteed that \(\frac{n}{2}\) is odd.
Input format
- The first line contains a single integer \(t\ (1\le t \le 100)\) denoting the number of test cases.
- The first line of each test case contains a single integer \(n\ (2 \le n \le 1e5)\) denoting the number of elements in the set.
- The second line of each test case contains \(n\) integers \(e\ (1 \le e \le 1e9)\).
Output format
Print \(t\) lines each containing a single line that contains \(k\).
By performing the XOR of k with each element we get the given set S
5⊕3=6
6⊕3=5
13⊕3=14
14⊕3=13
9⊕3=10
10⊕3=9
S' = {6,5,14,13,10,9} which is same as S={5,6,13,14,9,10}
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor