#include using namespace std; int main() { int n, m; cin >> n >> m; vector a(n), c(n); for (int i = 0; i < n; i++) cin >> a[i]; vector b(m); iota(b.begin(), b.end(), 0); for (int i = 0; i < m; i++) c[i] = 1; int nsc = 0; for (int i: a) nsc ^= i; random_device rd; mt19937 mt(rd()); for (int i = 0; i < 50000; i++) { // b[x]をa[y]に変える int x = mt() % m, y = mt() % n; int newsc = nsc ^ a[x] ^ a[y]; if (newsc > nsc && c[y] == 0) { nsc = newsc; b[x] = y; c[x] = 0; c[y] = 1; } } for (int i = 0; i < m - 1; i++) cout << a[b[i]] << ' '; cout << a[b[m - 1]] << '\n'; }