#include #include #include #include #include using namespace std; mt19937 mt(123); // [l,r] int randint(int l, int r) { return uniform_int_distribution(l, r)(mt); } int main() { int n, m; scanf("%d %d", &n, &m); vector a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } pair> mx; clock_t start = clock(); while (double(clock() - start) / CLOCKS_PER_SEC < 0.3) { vector p; vector used(n); int x = 0; while (p.size() < m) { int r = randint(0, n - 1); if (!used[r]) { used[r] = true; p.push_back(r); x ^= a[r]; } } mx = max(mx, make_pair(x, p)); } for (int i = 0; i < m; i++) { if (i > 0) putchar(' '); printf("%d", a[mx.second[i]]); } puts(""); }