XOR
Medium
Execution time limit is 2 seconds
Runtime memory usage limit is 256 megabytes
Aftandil has a sequence of integers a[1]
, a[2]
, ... , a[n]
. He decides to divide the sequence into exactly m consecutive parts.
The cost of each part is its xor-sum (bitwise exclusive-or), while the cost of the sequence is bitwise or-sum of its parts' costs.
Help Aftandil to find the minimum cost of the given sequence.
Input
The first line contains two integers n and m (1 ≤ n ≤ 200000, 1 ≤ m ≤ n).
The second line contains n integers a[1]
, a[2]
, ... , a[n]
(0 ≤ a[i]
≤ 10^9
).
Output
Print a single integer that denotes the minimum cost.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 71
Acceptance rate 14%