#include <bits/stdc++.h>
const int NN = 1 << 10;
using namespace std;
int main() {
  int n, k, x;
  int M[NN], N[NN];
  cin >> n >> k >> x;
  for (int index = 0; index < NN; index++) {
    M[index] = 0;
    N[index] = 0;
  }
  for (int index = 0; index < n; index++) {
    int tmp;
    cin >> tmp;
    M[tmp]++;
  }
  for (int index = 0; index < k; index++) {
    int res = 1;
    for (int index2 = 0; index2 < NN; index2++) {
      N[index2 ^ x] += (M[index2] + res) / 2;
      N[index2] += (M[index2] + 1 - res) / 2;
      res ^= (M[index2] % 2);
    }
    for (int index2 = 0; index2 < NN; index2++) {
      M[index2] = N[index2];
      N[index2] = 0;
    }
  }
  int minval, maxval;
  for (int index = 0; index < NN; index++) {
    if (M[index]) {
      minval = index;
      break;
    }
  }
  for (int index = NN - 1; index >= 0; index--) {
    if (M[index]) {
      maxval = index;
      break;
    }
  }
  cout << maxval << " " << minval << endl;
  return 0;
}
