#include <bits/stdc++.h>
using namespace std;
int freq[1100], aux[1100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, x, r, par, maxi, mini;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> r, freq[r]++;
  while (k--) {
    for (int i = 0; i < 1024; i++) aux[i] = freq[i];
    par = 0;
    for (int i = 0; i < 1024; i++) {
      if (freq[i] > 0) {
        int atual = i ^ x, change = freq[i] / 2;
        if (par == 0) change += freq[i] & 1;
        aux[i] -= change;
        aux[atual] += change;
        if (par == 0) {
          if (freq[i] % 2 == 0)
            par = 0;
          else
            par = 1;
        } else {
          if (freq[i] % 2 == 0)
            par = 1;
          else
            par = 0;
        }
      }
    }
    for (int i = 0; i < 1024; i++) freq[i] = aux[i];
  }
  maxi = 0;
  mini = INT_MAX;
  for (int i = 0; i < 1024; i++) {
    if (freq[i] > 0) {
      maxi = max(maxi, i);
      mini = min(mini, i);
    }
  }
  cout << maxi << " " << mini << "\n";
}
