#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; struct Timer { Timer() { reset(); } void reset() { beg = chrono::high_resolution_clock::now(); } ll elapsed() { chrono::high_resolution_clock::time_point en = chrono::high_resolution_clock::now(); return chrono::duration_cast(en - beg).count(); } private: chrono::high_resolution_clock::time_point beg; } timer; struct Xor128 { int rand() { unsigned t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return static_cast(w); } int rand(int ub) { int res = rand() % ub; return res < 0 ? res + ub : res; } int rand(int lb, int ub) { return lb + rand(ub - lb); } ll randll() { unsigned long long res = static_cast(rand()) << 32; return static_cast(res | rand()); } ll randll(ll ub) { ll res = randll() % ub; return res < 0 ? res + ub : res; } ll randll(ll lb, ll ub) { return lb + randll(ub - lb); } private: unsigned x = 123456789, y = 362436069, z = 521288629, w = static_cast(time(nullptr)); } xor128; int main() { int n, m; cin >> n >> m; vector a(n); REP(i, n) cin >> a[i]; int score = 0; REP(i, m) score ^= a[i]; vector ans(a.begin(), a.begin() + m); while (timer.elapsed() < 1400) { int x = 0; vector as; vector v(n, false); while (timer.elapsed() < 1400 && as.size() < m) { int idx = xor128.rand(n); if (!v[idx]) { x ^= a[idx]; as.emplace_back(a[idx]); v[idx] = true; } } if (x > score) { score = x; ans = as; } } REP(i, m) cout << ans[i] << " \n"[i + 1 == m]; return 0; }