Picking Out Numbers

Choose between 1 and k distinct integers from [l, r] minimizing the XOR of the chosen set, and output that minimum XOR.

Hard8Bit manipulationMathGreedyDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

Seonggwan wants to build a set SS that satisfies all of the following conditions.

  • Every element of SS is a natural number, and no two elements are equal.
  • Every element of SS is at least ll and at most rr.
  • The number of elements of SS is at least 11 and at most kk.

Choose SS so that the bitwise XOR of all its elements is as small as possible, and find that XOR value.

Input

The first line contains the natural numbers ll, rr, kk, separated by spaces. (1lr10121 \le l \le r \le 10^{12}, 1kmin(106,rl+1)1 \le k \le \min(10^6, r-l+1))

Output

Print the smallest XOR value on the first line. Several sets can reach that smallest value, but the output is that single value.