#include using namespace std; mt19937_64 rng; int main() { clock_t start = clock(); int n, m; cin >> n >> m; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector used(n), best_used(n); int score = 0, best = 0; for (int i = 0; i < m; i++) { used[i] = true; score ^= a[i]; } best_used = used; best = score; uniform_int_distribution<> dist(0, n - 1); while (clock() - start < CLOCKS_PER_SEC) { int x = dist(rng), y = dist(rng); if (used[x] == used[y]) continue; swap(used[x], used[y]); score ^= a[x] ^ a[y]; if (score > best) { best_used = used; best = score; } } int count = m; for (int i = 0; i < n; i++) { if (best_used[i]) { cout << a[i]; m--; if (m) cout << ' '; } } cout << endl; }