This page is still under construction.

Parts of this page are still being built. What you see may change.

Bitcoin Is God and I Am Invincible

Time limit1sMemory limit1024 MB

Summary
Choose exactly M values from N given numbers, repetition allowed, to maximize the bitwise XOR of the chosen values.
Level

Medium6 of 10

Topics
Dynamic programming, Bit manipulation, Brute force
Solved
No attempts yet

Problem

Chanho, who has four years of experience with coins and knows charts inside out, came up with the following formula that predicts the absolute value of the next monthly candle from the previous NN monthly candles.

(Absolute value of the next monthly candle) = the maximum over all choices of MM of the previous NN monthly candles, repetition allowed, of the bitwise xor of their absolute values

Given NN, MM, and the previous monthly candles AiA_i, find the absolute value of the next monthly candle.

Input

The first line gives NN and MM.

The second line gives A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N.

Output

Print the absolute value of the next monthly candle.

Constraints

  • 1≤M≤N≤1001 \leq M \leq N \leq 100
  • 0≤∣Ai∣<2100 \leq |A_i| < 2^{10}

Examples1

  1. Example 1

    Input
    3 2
    -1 2 3
    
    Expected output
    3