#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long arr[N];
long long cnt[N];
int32_t main() {
  long long n, k, x;
  cin >> n >> k >> x;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    cnt[arr[i]]++;
  }
  for (long long i = 0; i < k; i++) {
    long long temp[2000];
    for (long long i = 0; i < 2e3; i++) temp[i] = cnt[i];
    long long toggle = 1;
    for (long long j = 0; j < 2e3; j++) {
      if (cnt[j] == 0) continue;
      if (toggle == 0) {
        toggle++;
        cnt[j]--;
      }
      if (cnt[j] == 0) continue;
      if (cnt[j] % 2 == 0) {
        long long t = cnt[j] / 2;
        temp[j] -= t;
        temp[x xor j] += t;
        toggle = 1;
      } else {
        long long t = cnt[j] / 2;
        temp[j] -= t + 1;
        temp[x xor j] += t + 1;
        toggle = 0;
      }
    }
    for (long long i = 0; i < 2e3; i++) cnt[i] = temp[i];
  }
  long long mn = 99999999;
  long long mx = -99999999;
  for (long long i = 0; i < 2e3; i++) {
    if (cnt[i] > 0) {
      mn = min(mn, i);
      mx = max(mx, i);
    }
  }
  cout << mx << " " << mn << '\n';
}
