#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; unsigned int xor128(){ static unsigned int x=123456789, y=362436069, z=521288629, w=88675123; unsigned int t; t=(x^(x<<11)); x=y; y=z; z=w; return w=(w^(w>>19))^(t^(t>>8)); } vector solve(const vector& v, int N, int M){ bitset<100005> w; int score = 0; rep(i,M){ w[i] = 1; score ^= v[i]; } rep(t,1000){ /* for(int i=21; i>=0; i--){ if((score>>i)&1) cout << 1; else cout << 0; } cout << endl; */ int br = xor128()%22; int th = 1<<(br+1); vector p1, p0; vector q1, q0; rep(i,N){ if(v[i]>=th) continue; if(w[i]){ if((v[i]>>br)&1) p1.push_back(i); else p0.push_back(i); }else{ if((v[i]>>br)&1) q1.push_back(i); else q0.push_back(i); } } if((score>>br)&1){ if(p1.size()>1 && q0.size()>1){ int t_score = score; t_score ^= v[p1[0]]; t_score ^= v[p1[1]]; t_score ^= v[q0[0]]; t_score ^= v[q0[1]]; if(score <= t_score){ w[p1[0]] = 0; w[p1[1]] = 0; w[q0[0]] = 1; w[q0[1]] = 1; score ^= v[p1[0]]; score ^= v[p1[1]]; score ^= v[q0[0]]; score ^= v[q0[1]]; } } }else{ if(p1.size()>0 && q0.size()>0){ w[p1[0]] = 0; w[q0[0]] = 1; score ^= v[p1[0]]; score ^= v[q0[0]]; } else if(p0.size()>0 && q1.size()>0){ w[p0[0]] = 0; w[q1[0]] = 1; score ^= v[p0[0]]; score ^= v[q1[0]]; } } } cerr << score << endl; vector ret; rep(i,w.size()){ if(w[i]) ret.push_back(v[i]); } return ret; } int main(){ int N, M; cin >> N >> M; vector v; rep(i,N){ #ifdef LOCAL v.push_back(1+i); #else int a; cin >> a; v.push_back(a); #endif } sort(ALLOF(v)); vector ret = solve(v, N, M); #ifndef LOCAL rep(i,ret.size()){ if(i>0) cout << " "; cout << ret[i]; } cout << endl; #endif return 0; }