#include <cstdio>
#include <algorithm>
using namespace std;
int read(){
int val=0;
char c=getchar();
while(c<'0' || c>'9')
c=getchar();
while(c>='0' && c<='9')
val=val*10+c-'0',c=getchar();
return val;
}
typedef long long ll;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){ //ax+by=d
if (!b){
d=a;
x=1;
y=0;
return;
}else{
exgcd(b,a%b,d,y,x);
y-=x*(a/b);
}
}
ll crt(ll a,ll m,ll b,ll n){ //x=km+a=tn+b->km-tn=b-a
ll d,k,t;
exgcd(m,n,d,k,t);
ll w=(b-a);
//printf("m=%lld n=%lld t=%lld k=%lld w=%lld\n",m,n,t,k,w);
ll lcm=m*n;
return (k*w*m+a)%lcm;
}
const int p1=98869,p2=98873;
bool cnt1[98869],cnt2[98873];
int main(){
int n=read(),k=read(),xs=0;
while(n--){
int x=read();
xs^=x;
cnt1[x%p1]^=1;
cnt2[x%p2]^=1;
}
if (k==1){
printf("%d",xs);
return 0;
}
ll a1,b1,a2,b2;
bool flag=false;
for(int i=0;i<p1;i++){
if (!cnt1[i])
continue;
if (flag)
b1=i;
else a1=i,flag=true;
}
flag=false;
for(int i=0;i<p2;i++){
if (!cnt2[i])
continue;
if (flag)
b2=i;
else a2=i,flag=true;
}
ll w1=p1,w2=p2;
ll a=crt(a1,w1,a2,w2),b=crt(b1,w1,b2,w2);
if (a<0)
a+=w1*w2;
if (b<0)
b+=w1*w2;
if ((a^b)==xs){
if (a>b)
swap(a,b);
printf("%lld %lld",a,b);
}
else{
a=crt(a1,w1,b2,w2),b=crt(b1,w1,a2,w2);
if (a<0)
a+=w1*w2;
if (b<0)
b+=w1*w2;
if (a>b)
swap(a,b);
printf("%lld %lld",a,b);
}
}