#include <bits/stdc++.h>
using namespace std;
const int maxN = 1026;
int cnt1[maxN];
int cnt2[maxN];
int main(void) {
  int n, k, x;
  ios_base::sync_with_stdio(0);
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) {
    int pp;
    cin >> pp;
    cnt1[pp]++;
  }
  int *p1 = cnt1;
  int *p2 = cnt2;
  for (int i = 1; i <= k; i++) {
    int t = 1;
    for (int j = 0; j < maxN; j++) {
      if (p1[j]) {
        p2[j ^ x] += (p1[j] + t) >> 1;
        p2[j] += (p1[j] + 1 - t) >> 1;
        t ^= (p1[j] & 1);
        p1[j] = 0;
      }
    }
    swap(p1, p2);
  }
  vector<int> v;
  for (int i = 0; i < maxN; i++) {
    if (p1[i]) {
      v.push_back(i);
    }
  }
  cout << v.back() << " " << v[0] << endl;
  return 0;
}
