import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; ++i) { a[i] = sc.nextInt(); } int[] member = new int[m]; int answer = 0; for (int i = 0; i < m; ++i) { answer ^= a[i]; member[i] = i; } for (int i = 0; i < 1e7; ++i) { int rnd1 = (int) (Math.random() * m); int rnd2 = (int) (Math.random() * n); int tmp = answer ^ a[rnd2] ^ a[member[rnd1]]; if (tmp > answer) { member[rnd1] = rnd2; answer = tmp; } } for (int i = 0; i < m; ++i) { System.out.print(a[member[i]] + (i == m - 1 ? "\n" : " ")); } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }