#include <bits/stdc++.h>
using namespace std;
int podch[1100];
int newp[1100];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    podch[tmp]++;
  }
  for (int i = 0; i < k; i++) {
    int countwas = 0;
    for (int j = 0; j < 1100; j++) {
      newp[j] = 0;
    }
    for (int j = 0; j < 1100; j++) {
      int tmp = podch[j];
      if (podch[j] % 2 != 0) {
        if (countwas % 2 == 0) {
          newp[(j ^ x)] += (podch[j] / 2 + 1);
          newp[j] -= (podch[j] / 2 + 1);
        } else {
          newp[(j ^ x)] += (podch[j] / 2);
          newp[j] -= (podch[j] / 2);
        }
      } else {
        newp[(j ^ x)] += (podch[j] / 2);
        newp[j] -= (podch[j] / 2);
      }
      countwas += tmp;
    }
    for (int j = 0; j < 1100; j++) {
      podch[j] += newp[j];
    }
  }
  int kek = 0;
  for (int i = 0; i < 1100; i++) {
    if (podch[i]) {
      kek = i;
      break;
    }
  }
  int kek2 = 0;
  for (int i = 0; i < 1100; i++) {
    if (podch[i]) {
      kek2 = i;
    }
  }
  cout << kek2 << " " << kek << endl;
}
