#include <bits/stdc++.h>
using namespace std;
int q[1025], q2[1025];
vector<int> v;
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (not q[num]) v.push_back(num);
    q[num]++;
  }
  while (k--) {
    sort(v.begin(), v.end());
    memset(q2, 0, sizeof q2);
    vector<int> v2;
    bool even = true;
    for (int i = 0; i < (int)v.size(); i++) {
      int n_num = v[i] ^ x;
      if (even) {
        if (q[v[i]] & 1) {
          q2[n_num] += q[v[i]] / 2 + 1;
          q2[v[i]] += q[v[i]] - (q[v[i]] / 2 + 1);
          even = false;
        } else {
          q2[n_num] += q[v[i]] / 2;
          q2[v[i]] += q[v[i]] / 2;
        }
      } else {
        if (q[v[i]] & 1) {
          q2[n_num] += q[v[i]] / 2;
          q2[v[i]] += q[v[i]] - (q[v[i]] / 2);
          even = true;
        } else {
          q2[n_num] += q[v[i]] / 2;
          q2[v[i]] += q[v[i]] / 2;
        }
      }
    }
    for (int i = 0; i <= 1025; i++) {
      if (q2[i]) v2.push_back(i);
    }
    swap(v2, v);
    memcpy(q, q2, sizeof(q2));
  }
  sort(v.begin(), v.end());
  printf("%d %d\n", v[v.size() - 1], v[0]);
  return 0;
}
