#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 50;
const int X = 1024;
int n, k, x;
int arr[N];
int freq[X], freq2[X];
inline void brute() {
  int seen_till = 0;
  for (int i = 0; i < X; i++) {
    if (freq[i] != 0) {
      if (!seen_till) {
        int dec = (freq[i] + 1) / 2;
        freq2[i ^ x] += dec;
        freq2[i] += (freq[i] - dec);
      } else {
        int dec = (freq[i]) / 2;
        freq2[i ^ x] += dec;
        freq2[i] += (freq[i] - dec);
      }
    }
    seen_till += freq[i];
    seen_till %= 2;
  }
  for (int i = 0; i < X; i++) {
    freq[i] = freq2[i];
  }
  memset(freq2, 0, sizeof freq2);
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n >> k >> x;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    freq[arr[i]]++;
  }
  while (k--) {
    brute();
  }
  int mn = 1e9, mx = -1;
  for (int i = 0; i < X; i++) {
    if (freq[i] != 0) {
      if (i < mn) mn = i;
      if (i > mx) mx = i;
    }
  }
  cout << mx << ' ' << mn << endl;
}
