import Data.Bits
import Data.List

cal' s [] = []
cal' s (a:as) = 
  let s' = xor s a
  in
    s':(cal' s' as)

cal [] = []
cal a = (cal' 0 a) ++ (cal $ tail a)

ans [[_,k],an] =
  let xors = reverse $ sort $ cal an
  in
    xors!!(k-1)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  print o

