#include <bits/stdc++.h>
using namespace std;
inline int read(){
int x=0;char ch=getchar();
while(ch>'9'||ch<'0')ch=getchar();
while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x;
}
int bin[40], a[40], n, k, ans;
int main(){
int n = read(), k = read();
for(int i = 1; i <= 30; i++) bin[i] = 1<<i;
for(int i = 1, x; i <= n; i++){
x = read(); ans ^= x;
for(int i = 0; i <= 30; i++)
if(x&bin[i]) a[i] ^= x;
}
if(k == 1) return printf("%d\n", ans)&0;
int p = 30; while(!(ans&bin[p]))p--;
printf("%d %d\n", min(ans^a[p], a[p]), max(ans^a[p], a[p]));
}