Problem: Let denote the bitwise AND operation, and denote the bitwise OR operation.
You are given an array of length and a non-negative integer . You can perform at most operations on the array of the following type:
- Select an index () and replace with where is any integer between and inclusive. In other words, in an operation you can choose an index () and set the -th bit of to ().
Output the maximum possible value of after performing at most operations.
Input Format: The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains the integers and (, ).
Then a single line follows, containing integers describing the arrays ().
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, output a single line containing the maximum possible value of after performing at most operations.
Note: For the first test case, we can set the bit () of the last elements using the operations, thus obtaining the array [, , ], which has value equal to .
For the second test case, we can't perform any operations so the answer is just the of the whole array which is .