#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000 + 7;
const int num = 1000 * 1000 + 7;
const int N = 2000 + 7;
int a[num], b[num];
bool f[num];
vector<int> g[N];
map<int, int> ma;
long long ans;
int main() {
  int i, j, k, l, r, n, m, x;
  string s, s1;
  cin >> n >> k >> x;
  for (int i = 0; i < n; ++i) {
    cin >> r;
    a[r]++;
  }
  int t = -inf, t1 = inf;
  fill(b, b + 2007, 0);
  while (k--) {
    int z = 0;
    for (int i = 0; i < 2007; i++) {
      if (a[i] == 0) continue;
      if (z % 2 == 1) {
        b[i] += (a[i] + 1) / 2;
        int h = i ^ x;
        b[h] += a[i] / 2;
        z += a[i];
      } else {
        int h = i ^ x;
        b[h] += (a[i] + 1) / 2;
        b[i] += a[i] / 2;
        z += a[i];
      }
    }
    fill(a, a + 2007, 0);
    for (int i = 0; i < 2007; ++i) {
      a[i] = b[i], b[i] = 0;
    }
  }
  for (int i = 0; i < 2007; ++i) {
    if (a[i] == 0) continue;
    t = max(t, i);
    t1 = min(t1, i);
  }
  cout << t << " " << t1 << endl;
  return 0;
}
