#include <bits/stdc++.h>
using namespace std;
inline int read(int& a) {
  a = 0;
  int c = getchar();
  while (c <= 32) c = getchar();
  while (c >= '0' && c <= '9') a = a * 10 + c - '0', c = getchar();
  return c;
}
inline int writeln(int a, int b) { return printf("%d %d\n", a, b); }
int n, k, x;
int a[1 << 17];
int main() {
  read(n);
  read(k);
  read(x);
  for (int i = 0; i < n; ++i) read(a[i]);
  k = k % 64;
  int xarr[2] = {x, 0};
  for (int i = 0; i < k; ++i) {
    sort(a, a + n);
    for (int i = 0; i < n; ++i) a[i] ^= xarr[i & 1];
  }
  writeln(*max_element(a, a + n), *min_element(a, a + n));
}
