#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (T i : v) os << i << ' ';
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (T i : v) os << i << ' ';
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << '(' << v.first << ' ' << v.second << ')';
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' ';
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v) {
  for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' ';
  return os;
}
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long MOD = 1000000007;
const long long INF = 1e18;
const double EPS = 1e-5;
long long n, freq[1050], k, x, in, freq2[1050];
void solve() {
  memset(freq, 0, sizeof freq);
  memset(freq2, 0, sizeof freq2);
  cin >> n >> k >> x;
  for (long long i = 0; i < n; i++) {
    cin >> in;
    freq[in]++;
  }
  for (long long j = 0; j < k; j++) {
    long long nums_till_now = 0;
    for (long long i = 0; i < 1050; i++) {
      if (freq[i] == 0) continue;
      if (nums_till_now % 2 == 1) {
        freq2[i] += (freq[i] + 1) / 2;
        freq2[i ^ x] += freq[i] / 2;
      } else {
        freq2[i] += freq[i] / 2;
        freq2[i ^ x] += (freq[i] + 1) / 2;
      }
      nums_till_now += freq[i];
    }
    for (long long i = 0; i < 1050; i++) freq[i] = freq2[i];
    memset(freq2, 0, sizeof freq2);
  }
  long long mn = 1000000, mx = -1000000;
  for (long long i = 0; i < 1050; i++) {
    if (freq[i] > 0) {
      mn = min(mn, i);
      mx = max(mx, i);
    }
  }
  cout << mx << ' ' << mn << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  clock_t t1, t2;
  long long T = 1;
  while (T--) {
    solve();
  }
  t1 = clock();
  t2 = clock();
  cerr << "time taken: " << (t2 - t1) / (long double)CLOCKS_PER_SEC << "\n";
  return 0;
}
