In the lawless lands of the Binary West, three legendary figures govern the fate of numbers: The AND, The OR, and The XOR.
The AND is strict, seeking only the common ground among a group. The OR is greedy, claiming every bit of influence it can find. Finally, there is The XOR — the chaotic force that measures the tension between the strictness of The AND and the greed of The OR.
You are given a lineup of $$$n$$$ outlaws, where $$$a_i$$$ represents the bounty on the head of the $$$i$$$-th outlaw. You must choose a posse (subsequence) of at least two outlaws to minimize the tension.
Formally, for a chosen subsequence $$$a_{i_1}, a_{i_2}, \ldots, a_{i_k}$$$ (where $$$1 \le i_1 \lt i_2 \lt \cdots \lt i_k \le n$$$), the tension score is defined as: $$$$$$(a_{i_1} \mathbin{\&} a_{i_2} \mathbin{\&} \cdots \mathbin{\&} a_{i_k}) \oplus (a_{i_1} \mathbin{|} a_{i_2} \mathbin{|} \cdots \mathbin{|} a_{i_k})$$$$$$ Here, $$$\&$$$, $$$|$$$, and $$$\oplus$$$ denote the bitwise AND, OR, and XOR operators, respectively.
Find the minimum possible tension score among all subsequences of size at least $$$2$$$.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 3 \cdot 10^5$$$) — the number of outlaws.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$) — the bounties on the heads of the outlaws.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.
For each test case, output a single integer — the minimum possible tension score among all subsequences of size at least $$$2$$$.
231 2 321 1
10
In the first test case, the possible subsequences with size at least $$$2$$$ and their scores are:
| Name |
|---|


