#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int a[N], mi[N], ma[N];
int main() {
  int n, k, x;
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int i = 0;
  for (i = 1; i <= k; i++) {
    sort(a, a + n);
    mi[i] = a[0], ma[i] = a[n - 1];
    if (i >= 3) {
      if (mi[i] == mi[i - 1] && mi[i] == mi[i - 2] && ma[i] == ma[i - 1] &&
          ma[i] == ma[i - 2] && mi[i] == mi[i - 2] && ma[i] == ma[i - 2])
        break;
    }
    for (int j = 0; j < n; j += 2) a[j] ^= x;
  }
  sort(a, a + n);
  printf("%d %d\n", a[n - 1], a[0]);
  return 0;
}
