#include <bits/stdc++.h>
using namespace std;
int us[1100];
int us2[1100];
int main() {
  int ai, n, k, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) {
    cin >> ai;
    us[ai]++;
  }
  int j;
  int cur = 1;
  for (int i = 0; i < k; i++) {
    cur = 1;
    for (j = 0; j < 1100; j++) {
      if (!us[j]) continue;
      if (cur == 1) {
        if (us[j] % 2) cur = 0;
        us2[j ^ x] += us[j] / 2 + us[j] % 2;
        us2[j] += us[j] / 2;
      } else {
        if (us[j] % 2) cur = 1;
        us2[j ^ x] += us[j] / 2;
        us2[j] += us[j] / 2 + us[j] % 2;
      }
    }
    for (j = 0; j < 1100; j++) us[j] = us2[j];
    memset(us2, 0, sizeof us2);
  }
  int mx = -1, mn = 100000;
  for (int i = 0; i < 1100; i++) {
    if (us[i]) mx = max(mx, i), mn = min(mn, i);
  }
  cout << mx << ' ' << mn << '\n';
  return 0;
}
