#include <bits/stdc++.h>
using namespace std;
int a[100050];
int n, k, x;
int ans[105][100050];
const int INF = 0x3f3f3f3f;
int main() {
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int i;
  sort(a, a + n);
  if (k == 0) {
    printf("%d %d\n", a[n - 1], a[0]);
    return 0;
  }
  if (k == 1) {
    for (int j = 0; j < n; j += 2) a[j] = a[j] ^ x;
    sort(a, a + n);
    printf("%d %d\n", a[n - 1], a[0]);
    return 0;
  }
  if (k == 2) {
    for (i = 1; i <= 2; i++) {
      for (int j = 0; j < n; j += 2) a[j] = a[j] ^ x;
      sort(a, a + n);
    }
    printf("%d %d\n", a[n - 1], a[0]);
    return 0;
  }
  for (int i = 0; i < n; i++) ans[0][i] = a[i];
  sort(ans[0], ans[0] + n);
  for (int j = 1; j < 100; j++) {
    for (int i = 0; i < n; i++) ans[j][i] = ans[j - 1][i];
    for (int i = 0; i < n; i += 2) ans[j][i] = ans[j][i] ^ x;
    sort(ans[j], ans[j] + n);
  }
  int xunhuan = INF;
  int pos = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = i + 1; j < 100; j++) {
      int flag = 0;
      for (int h = 0; h < n; h++) {
        if (ans[i][h] != ans[j][h]) {
          flag = 1;
          break;
        }
      }
      if (!flag) {
        if (xunhuan > j - i + 1) {
          xunhuan = j - i;
          pos = j;
        }
      }
    }
  }
  if (k < pos) {
    sort(ans[k], ans[k] + n);
    printf("%d %d\n", ans[k][n - 1], ans[k][0]);
  } else {
    k -= pos;
    int re = k % xunhuan + pos;
    sort(ans[re], ans[re] + n);
    printf("%d %d\n", ans[re][n - 1], ans[re][0]);
  }
  return 0;
}
