#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
map<pair<long long, long long>, int> m;
long long p = 166425813649LL;
long long q = 73727170696867LL;
int main() {
  std::ios_base::sync_with_stdio(0);
  int cases, caseno = 0, n, i, j, k, x, t;
  bool damn = 0;
  long long sum, cnt;
  cin >> n >> k >> x;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++) {
    sum = (((sum * 10000LL) % p) + (1 + a[i])) % p;
    cnt = (((cnt * 10000LL) % q) + (1 + a[i])) % q;
  }
  m[make_pair(sum, cnt)] = 0;
  for (j = 1; j <= k; j++) {
    for (i = 1; i <= n; i++) {
      a[i] ^= x;
      i++;
    }
    sort(a + 1, a + n + 1);
    sum = cnt = 0;
    for (i = 1; i <= n; i++) {
      sum = (((sum * 10000LL) % p) + (1 + a[i])) % p;
      cnt = (((cnt * 10000LL) % q) + (1 + a[i])) % q;
    }
    if (k > j && m.find(make_pair(sum, cnt)) != m.end()) {
      damn = 1;
      t = m[make_pair(sum, cnt)];
      k = (k - j) % (j - t);
      break;
    }
    m[make_pair(sum, cnt)] = j;
  }
  if (damn) {
    for (j = 1; j <= k; j++) {
      for (i = 1; i <= n; i++) {
        a[i] ^= x;
        i++;
      }
      sort(a + 1, a + n + 1);
    }
  }
  int mn = 1000000, mx = 0;
  for (i = 1; i <= n; i++) {
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  cout << mx << " " << mn << '\n';
  return 0;
}
