#include <bits/stdc++.h>
using namespace std;
int cnt[1024], tmp[1024];
int main() {
  int n, k, maxm = 0, minm = INT_MAX, p, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> p, cnt[p]++;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 1024; j++) tmp[j] = cnt[j];
    int par = 0;
    for (int j = 0; j < 1024; j++) {
      if (cnt[j] > 0) {
        int curr = j ^ x;
        int change = cnt[j] / 2;
        if (par == 0) change += (cnt[j] & 1);
        tmp[j] -= change;
        tmp[curr] += change;
        par ^= (cnt[j] & 1);
      }
    }
    memcpy(cnt, tmp, sizeof(tmp));
  }
  for (int i = 0; i < 1024; i++)
    if (cnt[i] > 0) minm = min(minm, i), maxm = max(maxm, i);
  cout << maxm << " " << minm;
  return 0;
}
