#include #include #include #include #include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector a(n); int z = 0; for (int i = 0; i < n; i++) { cin >> a[i]; z |= a[i]; } int x = 0; for (int i = 0; i < m; i++) { x ^= a[i]; } int l = n - m; if (l > 0) { mt19937_64 rnd; for (int k = 0; k < 1 << 24; k++) { int i = rnd() % m; int j = rnd() % l + m; int y = x ^ a[i] ^ a[j]; if (y > x) { x = y; swap(a[i], a[j]); } if (x == z) break; } } for (int i = 0; i < m; i++) { cout << a[i] << " \n"[i == m - 1]; } return 0; }