#include <bits/stdc++.h>
using namespace std;
int freq[1100], 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, freq[p]++;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 1024; j++) tmp[j] = freq[j];
    int cnt = 0;
    for (int j = 0; j < 1024; j++) {
      if (freq[j] > 0) {
        int curr = (j ^ x), change;
        if (cnt % 2) {
          change = freq[j] / 2;
        } else {
          change = (freq[j] + 1) / 2;
        }
        tmp[j] -= change;
        tmp[curr] += change;
        cnt += freq[j];
      }
    }
    for (int j = 0; j < 1024; j++) freq[j] = tmp[j];
  }
  for (int i = 0; i < 1024; i++)
    if (freq[i] > 0) minm = min(minm, i), maxm = max(maxm, i);
  cout << maxm << " " << minm;
  return 0;
}
