import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); int[] array = new int[N]; for(int i = 0; i < N; i++){ array[i] = sc.nextInt(); } Arrays.sort(array); boolean[] used = new boolean[N]; int count = 0; long xor = 0; for(int bit = 31; bit >= 0 && count < M; bit--){ if(((1 << bit) & xor) != 0){ continue; } for(int i = 0; i < N; i++){ if(((1 << bit) & array[i]) == 0){ continue; } used[i] = true; xor ^= array[i]; count++; break; } } for(int i = 0; i < (M - count); i++){ if(used[i]){ continue; } used[i] = true; xor ^= array[i]; } //System.out.println(xor + " " + Arrays.toString(used)); boolean first = true; for(int i = 0; i < N; i++){ if(!used[i]){ continue; } System.out.print((first ? "" : " ") + (array[i])); first = false; } System.out.println(); } }