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(); long[] array = new long[N]; for(int i = 0; i < N; i++){ array[i] = sc.nextLong(); } Arrays.sort(array); boolean[] used = new boolean[N]; long max = 0; for(int i = 0; i < M; i++){ used[(N - 1) - i] = true; max ^= array[(N - 1) - i]; } for(int x = 0; x < 2000000; x++){ final int x1 = (int)(Math.random() * N); final int x2 = (int)(Math.random() * N); final int x3 = (int)(Math.random() * N); final int x4 = (int)(Math.random() * N); //final int x5 = (int)(Math.random() * N); //final int x6 = (int)(Math.random() * N); int count = 0; count += used[x1] ? 1 : -1; used[x1] = !used[x1]; count += used[x2] ? 1 : -1; used[x2] = !used[x2]; count += used[x3] ? 1 : -1; used[x3] = !used[x3]; count += used[x4] ? 1 : -1; used[x4] = !used[x4]; //count += used[x5] ? 1 : -1; used[x5] = !used[x5]; //count += used[x6] ? 1 : -1; used[x6] = !used[x6]; if(count != 0){ used[x1] = !used[x1]; used[x2] = !used[x2]; used[x3] = !used[x3]; used[x4] = !used[x4]; //used[x5] = !used[x5]; //used[x6] = !used[x6]; continue; } final long next_max = max ^ array[x1] ^ array[x2] ^ array[x3] ^ array[x4]/* ^ array[x5] ^ array[x6]*/; if(next_max > max){ max = next_max; }else{ used[x1] = !used[x1]; used[x2] = !used[x2]; used[x3] = !used[x3]; used[x4] = !used[x4]; //used[x5] = !used[x5]; //used[x6] = !used[x6]; } } 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(); } }