You have an array A of length N. You have to divide the array into atmost M consecutive segments such that the maximum bitwise OR of these segments is minimum.
Find the minimum possible maximum Bitwise OR of these segments if you divide optimally.
Input Format:
Output Format:
For each test case, print the minimum possible maximum Bitwise OR of these segments if you divide optimally.
Constraints:
1≤T≤101≤M≤N≤1051≤A[i]≤109
First test case:
We can divide A into [4]. Bitwise OR of these segments is 4. Hence, the answer is 4, which is the minimum possible.
Second test case:
We can divide A into [12,9] and [7]. Bitwise OR of these segments is 13,7. Hence, the answer is 13, which is the minimum possible.