#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using Pii = pair<int, int>;
constexpr int MAX = 200010;
constexpr int INF = 0x3F3F3F3F;
int a[MAX], b[2][MAX];
Pii Solve(int n, int k, int x) {
  int m = 0;
  for (int i = 0; i < n; ++i) {
    m = max(m, a[i]);
    m = max(m, a[i] ^ x);
  }
  memset(b, 0, sizeof(b));
  for (int i = 0; i < n; ++i) {
    ++b[0][a[i]];
  }
  int u = (k & 1);
  for (int t = 0; k--; t ^= 1) {
    for (int i = 0; i <= m; ++i) {
      b[t ^ 1][i] = b[t][i];
    }
    int cnt = 0;
    for (int i = 0; i <= m; ++i) {
      int d = ((b[t][i] + 1 - (cnt & 1)) >> 1);
      cnt += b[t][i];
      b[t ^ 1][i] -= d;
      b[t ^ 1][i ^ x] += d;
    }
  }
  Pii ret = {-INF, INF};
  for (int i = 0; i <= m; ++i) {
    if (b[u][i]) {
      ret.first = max(ret.first, i);
      ret.second = min(ret.second, i);
    }
  }
  return ret;
}
int main() {
  int n, k, x;
  while (~scanf("%d%d%d", &n, &k, &x)) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
    }
    auto ans = Solve(n, k, x);
    printf("%d %d\n", ans.first, ans.second);
  }
  return 0;
}
