#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define endl '\n'
#define pii pair<int,int>
#define mapii map<int,int>
#define mapll map<ll,ll>
#define mapci map<char,int>
#define mapcl map<char,ll>
#define mapsi map<string,int>
#define mapsl map<string,ll>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vd vector<double,double>
#define all(c) c.begin(),c.end()
#define F first
#define S second
#define mp make_pair
#define ftc(x) cerr << #x << ": " << x << " " << endl;
#define PI acos(-1)
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define optimize ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sqr(a) ((a)*(a))
int main()
{
int tst;
tst = 1;
// cin >> tst;
while(tst--)
{
ll i,j,k,l,m,n,x;
cin >> n >> k>> x;
ll ans = 0;
ll ar[n+10];
ll ar1[n+10];
ll ar2[n+10];
for(i=0; i<n; i++)cin >> ar[i];
sort(ar,ar+n);
for(i=0; i<n; i++)ar1[i] = ar[i];
for(i=0; i<n; i+=2)ar1[i] = ar[i]^x;
sort(ar1,ar1+n);
for(i=0; i<n; i++)ar2[i] = ar1[i];
for(i=0; i<n; i+=2)ar2[i] = ar1[i]^x;
sort(ar2,ar2+n);
if(k%2)
{
cout << ar1[n-1] << " " << ar1[0] << endl;
}
else cout << ar2[n-1] << " " << ar2[0] << endl;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CiAKI2RlZmluZSAgICAgICAgIHBiICAgICAgICAgcHVzaF9iYWNrCiNkZWZpbmUgICAgICAgICBzZih4KSAgICAgIHNjYW5mKCIlZCIsJngpCiNkZWZpbmUgICAgICAgICBzZmwoeCkgICAgIHNjYW5mKCIlbGxkIiwmeCkKI2RlZmluZSAgICAgICAgIHBmKHgpICAgICAgcHJpbnRmKCIlZFxuIix4KQojZGVmaW5lICAgICAgICAgcGZsKHgpICAgICBwcmludGYoIiVsbGRcbiIseCkKI2RlZmluZSAgICAgICAgIGVuZGwgICAgICAgJ1xuJwojZGVmaW5lICAgICAgICAgcGlpICAgICAgICBwYWlyPGludCxpbnQ+CiNkZWZpbmUgICAgICAgICBtYXBpaSAgICAgIG1hcDxpbnQsaW50PgojZGVmaW5lICAgICAgICAgbWFwbGwgICAgICBtYXA8bGwsbGw+CiNkZWZpbmUgICAgICAgICBtYXBjaSAgICAgIG1hcDxjaGFyLGludD4KI2RlZmluZSAgICAgICAgIG1hcGNsICAgICAgbWFwPGNoYXIsbGw+CiNkZWZpbmUgICAgICAgICBtYXBzaSAgICAgIG1hcDxzdHJpbmcsaW50PgojZGVmaW5lICAgICAgICAgbWFwc2wgICAgICBtYXA8c3RyaW5nLGxsPgojZGVmaW5lICAgICAgICAgcGxsICAgICAgICBwYWlyPGxsLGxsPgojZGVmaW5lICAgICAgICAgdmkgICAgICAgICB2ZWN0b3I8aW50PgojZGVmaW5lICAgICAgICAgdmwgICAgICAgICB2ZWN0b3I8bGw+CiNkZWZpbmUgICAgICAgICB2ZCAgICAgICAgIHZlY3Rvcjxkb3VibGUsZG91YmxlPgojZGVmaW5lICAgICAgICAgYWxsKGMpICAgICBjLmJlZ2luKCksYy5lbmQoKQojZGVmaW5lICAgICAgICAgRiAgICAgICAgICBmaXJzdAojZGVmaW5lICAgICAgICAgUyAgICAgICAgICBzZWNvbmQKI2RlZmluZSAgICAgICAgIG1wICAgICAgICAgbWFrZV9wYWlyCiNkZWZpbmUgICAgICAgIGZ0Yyh4KSAgICAgIGNlcnIgPDwgI3ggPDwgIjogIiA8PCB4IDw8ICIgIiA8PCBlbmRsOwojZGVmaW5lICAgICAgICAgUEkgICAgICAgICBhY29zKC0xKQojZGVmaW5lICAgICAgICBsY20oYSxiKSAgICgoYSpiKS9fX2djZChhLGIpKQojZGVmaW5lICAgICAgICBvcHRpbWl6ZSAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKE5VTEwpOwojZGVmaW5lICAgICAgICBzcXIoYSkgICAgICAgKChhKSooYSkpCiAKaW50IG1haW4oKQp7CiAgICBpbnQgdHN0OwogCiAgICB0c3QgPSAxOwogCiAgICAvLyBjaW4gPj4gdHN0OwogCiAgICB3aGlsZSh0c3QtLSkKICAgIHsKICAgICAgICBsbCBpLGosayxsLG0sbix4OwogCiAgICAgICAgY2luID4+IG4gPj4gaz4+IHg7CiAKICAgICAgICBsbCBhbnMgPSAwOwogCiAgICAgICAgbGwgYXJbbisxMF07CiAgICAgICAgbGwgYXIxW24rMTBdOwogICAgICAgIGxsIGFyMltuKzEwXTsKIAogICAgICAgIGZvcihpPTA7IGk8bjsgaSsrKWNpbiA+PiBhcltpXTsKIAogICAgICAgIHNvcnQoYXIsYXIrbik7CiAKICAgICAgICBmb3IoaT0wOyBpPG47IGkrKylhcjFbaV0gPSBhcltpXTsKICAgICAgICBmb3IoaT0wOyBpPG47IGkrPTIpYXIxW2ldID0gYXJbaV1eeDsKIAogICAgICAgIHNvcnQoYXIxLGFyMStuKTsKIAogICAgICAgIGZvcihpPTA7IGk8bjsgaSsrKWFyMltpXSA9IGFyMVtpXTsKICAgICAgICBmb3IoaT0wOyBpPG47IGkrPTIpYXIyW2ldID0gYXIxW2ldXng7CiAKICAgICAgICBzb3J0KGFyMixhcjIrbik7CiAKICAgICAgICBpZihrJTIpCiAgICAgICAgewogICAgICAgICAgICBjb3V0IDw8IGFyMVtuLTFdIDw8ICIgIiA8PCBhcjFbMF0gPDwgZW5kbDsKICAgICAgICB9CiAgICAgICAgZWxzZSBjb3V0IDw8IGFyMltuLTFdIDw8ICIgIiA8PCBhcjJbMF0gPDwgZW5kbDsKICAgIH0KfQ==