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(); long[] array = new long[N]; for(int i = 0; i < N; i++){ array[i] = sc.nextLong(); } boolean[] use = new boolean[N]; long max = 0; for(int i = 0; i < M; i++){ use[i] = true; max ^= array[i]; } while(true){ for(int out = 0; out < N; out++){ if(use[out]){ continue; } for(int in = 0; in < N; in++){ if(!use[in]){ continue; } final long next_max = max ^ array[out] ^ array[in]; if(next_max > max){ max = next_max; use[out] = false; use[in] = true; } } } break; } for(int i = 0; i < N; i++){ if(!use[i]){ continue; } System.out.print((i == 0 ? "" : " ") + (array[i])); } System.out.println(); } }