#P8019. [ONTAK2015] OR-XOR

[ONTAK2015] OR-XOR

Problem Description

Given a sequence a1,a2,,ana_1, a_2, \cdots, a_n of length nn, split it into mm consecutive segments. Let the cost of the ii-th segment be cic_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,mn, m.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n.

Output Format

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

3 2
1 5 7
3

Hint

For 100%100\% of the testdata, 1mn5×1051 \leq m \leq n \leq 5 \times 10^5, 0ai10180 \leq a_i \leq 10^{18}.

Translated by ChatGPT 5