#include <bits/stdc++.h>
using namespace std;
int pr[1100];
int nx[1100];
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    pr[t]++;
  }
  for (int t = 0; t < k; ++t) {
    int cur = 0;
    for (int j = 0; j < 1100; ++j) {
      if (pr[j] == 0) continue;
      int r = (pr[j] + (cur % 2 == 0)) / 2;
      nx[j ^ x] += r;
      nx[j] += pr[j] - r;
      cur += pr[j];
    }
    swap(nx, pr);
    for (int j = 0; j < 1100; ++j) nx[j] = 0;
  }
  for (int i = 1099; i >= 0; --i)
    if (pr[i] != 0) {
      cout << i << " ";
      break;
    }
  for (int i = 0; i < 1100; ++i)
    if (pr[i] != 0) {
      cout << i << endl;
      break;
    }
  return 0;
}
