from collections import defaultdict from itertools import chain def main(): N, M = map(int, input().split()) A = set(map(int, input().split())) if M == 1: print(max(N)) return if N == M: print(*A, sep=' ') return num = digits(A) rm = set() n = N - M ans = [] while len(rm) < n: for i, j in sorted(num.items(), reverse=1): if not len(j) % 2: rm.add(num[i].pop(0)) if len(rm) == n: for k in num.values(): ans.extend(k) print(*ans, sep=' ') return break else: break num = digits(list(chain.from_iterable(num.values()))) for i, j in sorted(num.items()): while len(j) > 0: rm.add(num[i].pop(-1)) if len(rm) == n: for k in num.values(): ans.extend(k) print(*ans, sep=' ') return def digits(a): num = defaultdict(list) for i in a: l = len(f'{i:b}') - 1 num[l].append(i) return num main()