The ORZ Wizard loves to conjure numbers. You decided to test its strength and gave it an array a
consisting of n
integers, as well as an integer z
. The numbering of array elements starts from 1.
The ORZ wizard performs the following operation any number (possibly zero) times:
- It selects an integer
i
such that 1<= i <= n. Then he whispers a spell and after that at the same time the number ai
turns into a number equal to (a i or z
), and the number z turns into a number equal to (ai sub>and z
).
Here or
and and
denote the bitwise OR and bitwise AND operations, respectively.
Find the maximum possible value of the maximum element in the array a
after some (possibly zero) number of transformations.
Input
The first line of the input contains two integers: n and z (1 <= n <= 2000, 0 <= z < 2
30). The second line of the input contains n integers:
a1
,
a2
,
...,
an
(0 <=
ai code><230). It is guaranteed that the sum of n
values over all test cases does not exceed 104.
Imprint
Print the answer to the problem.
Examples
# |
Input |
Output |
Note |
1 |
2 3
3 4 |
7 |
One of the optimal sequences of actions is the following:
- Perform operation on
i = 1 . Now a1 becomes (3 or 3) = 3 and z becomes (3 and 3) = 3 .
- Perform operation for
i = 2 . Now a2 becomes (4 or 3) = 7 , and z becomes equal to (3 and 3) = 0 .
- Perform operation on
i = 1 . Now a1 becomes (3 or 0) = 3 and z becomes (3 and 0) = 0 .
After these operations, the sequence a becomes equal to [3,7] , and the maximum value in it is equal to 7. It can be proved that the maximum value in a cannot exceed 7 in any sequence of operations, so the answer is 7.
|
2 |
5 5
0 2 4 6 8
| 13 |
|