#P8019. Minimize Partition Cost

    ID: 21203 Type: Default 1000ms 256MiB

Minimize Partition Cost

Minimize Partition Cost

Given a sequence of length \(n\): \(a_1, a_2, \ldots, a_n\), partition it into \(m\) contiguous segments. For the \(i\)th segment, let its cost \(c_i\) be the XOR of all numbers in that segment. The total cost is defined as

[ ; c_1 \operatorname{or} c_2 \operatorname{or} \cdots \operatorname{or} c_m ;, ]

and your task is to compute the minimum total cost achievable by an appropriate segmentation.

inputFormat

The first line contains two integers \(n\) and \(m\) with \(1 \le m \le n\). The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\).

outputFormat

Output the minimum possible total cost.

sample

3 2
1 2 3
1