#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(); } { for(int b=21; b>=0; b--){ int x = 1<<(b+1); if(((score>>b)&1) == 0){ int p = -1, q = -1; int pmn = 10000000, qmx = -1; rep(i,ret.size()){ if(x > ret[i] && ((ret[i]>>b)&1) == 1){ if(pmn > ret[i]){ p = i; pmn = ret[i]; } } } if(p != -1){ rep(i,v.size()){ if(x > v[i] && ((v[i]>>b)&1) == 0){ if(qmx < v[i]){ q = i; qmx = v[i]; } } } }else{ rep(i,ret.size()){ if(x > ret[i] && ((ret[i]>>b)&1) == 0){ if(pmn > ret[i]){ p = i; pmn = ret[i]; } } } rep(i,v.size()){ if(x > v[i] && ((v[i]>>b)&1) == 1){ if(qmx < v[i]){ q = i; qmx = v[i]; } } } } if(p != -1 && q != -1){ score ^= ret[p]; score ^= v[q]; swap(ret[p],v[q]); } } } } cerr << score << endl; #ifndef LOCAL rep(i,ret.size()){ if(i>0) cout << " "; cout << ret[i]; } cout << endl; #endif return 0; }