#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x, a[100005];
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  k %= 64;
  while (k--) {
    sort(a, a + n);
    for (int j = 0; j < n; j += 2) a[j] ^= x;
  }
  sort(a, a + n);
  cout << a[n - 1] << " " << a[0] << endl;
  return 0;
}
