#include <iostream>
#include <cstdio>
#include<algorithm>
#define inf 1e9
#define ll long long
#define maxn 401000
#define y1 fuck
#define For(i,j,k) for(ll i=j;i<=k;i++)
#define Dow(i,j,k) for(ll i=k;i>=j;i--)
using namespace std;
inline ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; }
inline void write(ll x){ if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10); putchar(x%10+'0'); }
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
ll n,k,ans1[40][2],tw[40],x;
inline void doit1()
{
ll ans=0;
For(i,1,n) x=read(),ans^=x;
writeln(ans);
exit(0);
}
inline void doit2()
{
tw[0]=1;
For(i,1,60) tw[i]=tw[i-1]*2LL;
For(i,1,n)
{
x=read();
For(j,0,60) if(x&(tw[j])) ans1[j][1]^=x;else ans1[j][0]^=x;
}
For(i,1,60) if(ans1[i][1]!=ans1[i][0]&&ans1[i][1]!=0&&ans1[i][0]!=0) {writeln(min(ans1[i][1],ans1[i][0])),writeln(max(ans1[i][1],ans1[i][0]));exit(0);}
}
int main()
{
// freopen("water.in","r",stdin);freopen("water.out","w",stdout);
n=read();k=read();
if(k==1) doit1();
if(k==2) doit2();
}