#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, x;
  cin >> n >> k >> x;
  int a[1024], prefixSum[1024];
  memset(a, 0, sizeof(a));
  memset(prefixSum, 0, sizeof(prefixSum));
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    a[y]++;
  }
  for (int i = 0; i < k; i++) {
    int l, r, currsum = 0;
    for (int i = 0; i < 1024; i++) {
      if (a[i] != 0) {
        l = i;
        break;
      }
    }
    for (int j = 1024; j >= 0; j--) {
      if (a[j] != 0) {
        r = i;
        break;
      }
    }
    for (int m = 0; m < 1024; m++) {
      if (a[m] > 0) {
        int newpos = (m ^ x);
        if (a[m] % 2 == 0) {
          prefixSum[newpos] += a[m] / 2;
          prefixSum[m] += a[m] / 2;
        }
        if ((a[m] % 2 != 0) && (currsum % 2 == 0)) {
          prefixSum[newpos] += (a[m] / 2) + 1;
          prefixSum[m] += a[m] / 2;
        }
        if ((a[m] % 2 != 0) && (currsum % 2 != 0)) {
          prefixSum[newpos] += a[m] / 2;
          prefixSum[m] += a[m] / 2 + 1;
        }
        currsum += a[m];
      }
    }
    for (int i = 0; i < 1024; i++) {
      a[i] = prefixSum[i];
    }
    memset(prefixSum, 0, sizeof(prefixSum));
  }
  for (int i = 1023; i >= 0; i--) {
    if (a[i] != 0) {
      cout << i << " ";
      break;
    }
  }
  for (int i = 0; i < 1024; i++) {
    if (a[i] != 0) {
      cout << i << " ";
      break;
    }
  }
  cout << "\n";
  return 0;
}
