#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)); } 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; int score = 0; rep(i,M){ ret.push_back(v[N-1-i]); score ^= v[N-1-i]; } rep(i,M){ v.pop_back(); } rep(i,100){ for(int b=21; b>=0; b--){ int x = 1<<(b+1); if(((score>>b)&1) == 0){ vector p, q; rep(i,ret.size()){ if(x > ret[i] && ((ret[i]>>b)&1) == 1){ p.push_back(i); } } if(p.size() > 0){ rep(i,v.size()){ if(x > v[i] && ((v[i]>>b)&1) == 0){ q.push_back(i); break; } } }else{ rep(i,ret.size()){ if(x > ret[i] && ((ret[i]>>b)&1) == 0){ p.push_back(i); break; } } rep(i,v.size()){ if(x > v[i] && ((v[i]>>b)&1) == 1){ q.push_back(i); break; } } } if(p.size()>0 && q.size()>0){ int pi = p[xor128()%(p.size())]; int qi = q[xor128()%(q.size())]; score ^= ret[pi]; score ^= v[qi]; swap(ret[pi],v[qi]); } } } } cerr << score << endl; #ifndef LOCAL rep(i,ret.size()){ if(i>0) cout << " "; cout << ret[i]; } cout << endl; #endif return 0; }