N, M = gets.split.map &:to_i A = gets.split.map(&:to_i).sort.reverse m = N - M res = A.inject(:^) sub = [] A.group_by{|a|Math.log2(a).floor}.each{|k, v| oddp = res & 2**k != 0 v.pop if oddp v.each{|n| res ^= n sub << n m -= 1 if m == 0 puts (A - sub)*" " exit end } } puts (A - sub).max(M)*" "