#include using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define PQ priority_queue #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it) #define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it) template bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } template T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- #define bit(b, i) (((b) >> (i)) & 1) int n, m, a[100000]; int B[16], C[16]; bool f[100000]; vector ans; int bc(int x) { int v = 0; while(x) { v += x % 2; x /= 2; } return v; } int main() { cin >> n >> m; inc(i, n) { cin >> a[i]; } inc(i, n) { B[a[i] >> 16]++; } auto ma = MP(-1, 0); inc(i, 1 << 16) { if(bc(i) % 2 != m % 2) { continue; } int x = 0, c = 0; inc(j, 16) { x ^= bit(i, j) * j; if(bit(i, j) && B[j] == 0) { c = -1e7; break; } c += (bit(i, j) ? (B[j] - 1) / 2 * 2 + 1 : B[j] / 2 * 2); } if(c >= m) { setmax(ma, MP(x, i)); } } int S = ma.SE; int r = m; inc(j, 16) { C[j] = bit(S, j); r -= C[j]; } assert(r >= 0); inc(j, 16) { while(r - 2 >= 0 && C[j] + 2 <= B[j]) { C[j] += 2; r -= 2; } } int sum = 0; inc(j, 16) { assert(C[j] <= B[j]); sum += C[j]; } assert(sum == m); inc(i, n) { if(C[a[i] >> 16] > 0) { f[i] = true; C[a[i] >> 16]--; } } inc(i, n) { if(f[i]) { ans.PB(a[i]); } } assert(ans.size() == m); inc(i, m) { cout << (i == 0 ? "" : " ") << ans[i]; } return 0; }