#include <bits/stdc++.h>
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  int MAX = 1024;
  vector<int> V(n), P(MAX, 0);
  for (auto &el : V) {
    cin >> el;
    P[el]++;
  }
  for (int i = 0; i < k; i++) {
    vector<int> noweP(MAX, 0);
    int ile_zrobilem = 0;
    for (int j = 0; j < MAX; j++) {
      int zmiana = P[j] / 2, bezzmiany = P[j] / 2;
      if ((ile_zrobilem & 1) == 0 && (P[j] & 1) == 1)
        zmiana++;
      else if (P[j] & 1)
        bezzmiany++;
      noweP[j] += bezzmiany;
      noweP[j ^ x] += zmiana;
      ile_zrobilem += P[j];
    }
    P = noweP;
  }
  for (int i = MAX - 1; i >= 0; i--)
    if (P[i]) {
      cout << i << " ";
      break;
    }
  for (int i = 0; i < MAX; i++)
    if (P[i]) {
      cout << i;
      break;
    }
  return 0;
}
