#include <bits/stdc++.h>
using namespace std;
vector<int> a;
vector<vector<int> > lst, lt;
set<vector<int> > lst2;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, k, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(), a.end());
  lst.push_back(a);
  lst2.insert(a);
  int cnt = 0;
  while (cnt < k) {
    cnt++;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i += 2) {
      a[i] ^= x;
    }
    sort(a.begin(), a.end());
    if (lst2.find(a) != lst2.end()) {
      break;
    }
    lst2.insert(a);
    lst.push_back(a);
  }
  if (k < lst.size()) {
    cout << lst[k].back() << " " << lst[k].front();
    exit(0);
  }
  int start = 0;
  for (int i = 0; i < lst.size(); i++) {
    if (lst[i] == a) {
      start = i;
      break;
    } else
      k--;
  }
  for (int i = start; i < lst.size(); i++) {
    lt.push_back(lst[i]);
  }
  k %= lt.size();
  a = lt[k];
  cout << a.back() << " " << a.front() << endl;
  return 0;
}
