#include <bits/stdc++.h>
using namespace std;
vector<int> Guards;
int main() {
  int n, k, x;
  int dummy;
  scanf("%d %d %d", &n, &k, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &dummy);
    Guards.push_back(dummy);
  }
  sort(Guards.begin(), Guards.end());
  k %= 64;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j += 2) {
      Guards[j] = Guards[j] ^ x;
    }
    sort(Guards.begin(), Guards.end());
  }
  printf("%d %d\n", Guards[n - 1], Guards[0]);
  return 0;
}
