#include <bits/stdc++.h>
using namespace std;
int woah[2][1024] = {0};
int main() {
  ios::sync_with_stdio(false);
  int n, k, x, a;
  cin >> n >> k >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    woah[0][a]++;
  }
  for (int i = 1; i <= k; ++i) {
    int count = 0;
    for (int j = 0; j < 1024; ++j) {
      woah[i % 2][j ^ x] += woah[(i - 1) % 2][j] / 2;
      woah[i % 2][j] += woah[(i - 1) % 2][j] / 2;
      if (count % 2 == 0 && woah[(i - 1) % 2][j] % 2 == 1)
        woah[i % 2][j ^ x]++;
      else if (count % 2 == 1 && woah[(i - 1) % 2][j] % 2 == 1)
        woah[i % 2][j]++;
      count += woah[(i - 1) % 2][j];
      woah[(i - 1) % 2][j] = 0;
    }
  }
  for (int i = 1023; i >= 0; --i) {
    if (woah[k % 2][i] != 0) {
      cout << i << " ";
      break;
    }
  }
  for (int i = 0; i < 1024; ++i) {
    if (woah[k % 2][i] != 0) {
      cout << i << "\n";
      break;
    }
  }
  return 0;
}
