#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3000000+9;
int a[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, res;
cin >> n >> k;
res = 0;
for(int i = 0; i < n; i++){
cin >> a[i];
res ^= a[i];
}
if(k == 1){
cout << res << endl;
}
else {
int x, y, flag;
flag = 1;
x = 0, y = 0;
for(int i = 0; i < 32; i++){ //找到1出现的位置
if(res & (flag<<=i)){
break;
}
}
for(int i = 0; i < n; i++){
if(flag & a[i]){ //进行分组
x ^= a[i];
}else{
y ^= a[i];
}
}
if(x > y) swap(x,y);
cout << x << " " << y << endl;
}
return 0;
}
https://www.luogu.org/problem/T109936?contestId=23517