#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int N = 1e5 + 10, M = 1024;
int a[N], cnt[N], n, k, x;
int main() {
  scanf("%d %d %d", &n, &k, &x);
  int ai;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ai);
    a[ai]++;
  }
  for (int ca = 1; ca <= k; ca++) {
    int tot = 0, y;
    for (int i = 0; i <= M; i++) {
      if (tot & 1)
        cnt[i] = a[i] >> 1;
      else
        cnt[i] = (a[i] + 1) >> 1;
      tot += a[i];
    }
    for (int i = 0; i <= M; i++) a[i] -= cnt[i], a[i ^ x] += cnt[i];
  }
  for (int i = M; i >= 0; i--)
    if (a[i]) {
      printf("%d ", i);
      break;
    }
  for (int i = 0; i <= M; i++)
    if (a[i]) {
      printf("%d\n", i);
      break;
    }
  return 0;
}
