#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
const int mod = 1e9 + 7;
int cnt[N], fre[N];
int mn, mx;
int main() {
  ios::sync_with_stdio(false);
  int n, k, x;
  cin >> n >> k >> x;
  mn = mod;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    cnt[y]++;
    fre[y]++;
  }
  for (int i = 0; i < k; i++) {
    int prev = 0;
    for (int j = 0; j < 1024; j++) {
      if (cnt[j] == 0) {
        continue;
      }
      if (prev & 1) {
        int temp = cnt[j] / 2;
        fre[j] -= temp;
        fre[j ^ x] += temp;
      } else {
        int temp = cnt[j] / 2;
        if (cnt[j] & 1) {
          temp++;
        }
        fre[j] -= temp;
        fre[j ^ x] += temp;
      }
      prev += cnt[j];
    }
    for (int j = 0; j < 1024; j++) {
      cnt[j] = fre[j];
    }
  }
  for (int j = 0; j < 1024; j++) {
    if (cnt[j]) {
      mn = min(mn, j);
      mx = max(mn, j);
    }
  }
  cout << mx << " " << mn << endl;
  return 0;
}
