Bitwise Party#12463

Bitwise Party

2 seconds
256 megabytes
Hard

You are given an array consisting of elements numbered 1,2,...,n.

You can do the following operation at most once.

Find the minimum value of a_1 \space | \space a_2 \space | \space ... \space |\space a_n after doing the previous operation.

Here denotes The Bitwise OR operation while denotes The Bitwise AND operation

Input

The first line contains a single integer (1 \le t \le 10^4) the number of test cases.

The first line of each test case contains a single integer (1\le n\le 2\cdot 10^5).

The second line of each test case contains integers (0 \le a_i < 2^{31}).

It's guaranteed that the sum of over all test cases does not exceed 2 \cdot 10^5.

Output

For each test case, print a single integer , the minimum value of a_1 | a_2 | ... | a_n.

Examples

Example 1

Loading
Loading

Note

In the first test case you can choose l = 2 , r = 3 , to obtain the array a = [1 , 0 , 1]

a_1 | a_2 | a_3 = 1 | 0 | 1 = 1 which is the minimum answer.

Scoring

  • Subtask ( points): No additional constraints.