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; } int max_index = -1; long max_value = -1; for(int i = 0; i < N; i++){ if(used[i]){ continue; } if(((1 << bit) & array[i]) == 0){ continue; } if(max_value < array[i]){ max_index = i; max_value = array[i]; } } if(max_index >= 0){ used[max_index] = true; xor ^= max_value; count++; } } //System.out.println(xor + " " + count + " : " + Arrays.toString(used)); for(int i = 0; i < N && count < M; i++){ if(used[i]){ continue; } used[i] = true; xor ^= array[i]; count++; } //System.out.println(xor + " " + count + " : " + 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(); } }