#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, x;
  cin >> n >> k >> x;
  int cont[1025];
  for (int i = 0; i < 1025; i++) cont[i] = 0;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    cont[b]++;
  }
  int cont2[1025];
  for (int i = 0; i < k; i++) {
    int flag = true;
    for (int j = 0; j < 1025; j++) cont2[j] = 0;
    int pos = 0;
    for (int j = 0; j < 1025; j++) {
      int xorzin = j ^ x;
      if (cont[j] % 2 == 1) {
        if (flag) {
          cont2[xorzin] += cont[j] / 2 + cont[j] % 2;
          cont2[j] += cont[j] / 2;
        } else {
          cont2[xorzin] += cont[j] / 2;
          cont2[j] += cont[j] / 2 + cont[j] % 2;
        }
        flag = !flag;
      } else {
        cont2[xorzin] += cont[j] / 2;
        cont2[j] += (cont[j] / 2);
      }
    }
    for (int j = 0; j < 1025; j++) cont[j] = cont2[j];
  }
  int pos = 1024;
  while (cont[pos] == 0) pos--;
  cout << pos << " ";
  pos = 0;
  while (cont[pos] == 0) pos++;
  cout << pos << endl;
  return 0;
}
