P8019 [ONTAK2015] OR-XOR

Description

Given a sequence $a_1, a_2, \cdots, a_n$ of length $n$, split it into $m$ consecutive segments. Let the cost of the $i$-th segment be $c_i$, which is the XOR sum of all numbers in that segment. Then the total cost is $c_1 \operatorname{or} c_2 \operatorname{or} \cdots \operatorname{or} c_m$. Find the minimum possible total cost.

Input Format

The first line contains two integers $n, m$. The second line contains $n$ integers $a_1, a_2, \cdots, a_n$.

Output Format

Output one line containing one integer, which is the required value.

Explanation/Hint

For $100\%$ of the testdata, $1 \leq m \leq n \leq 5 \times 10^5$, $0 \leq a_i \leq 10^{18}$. Translated by ChatGPT 5