#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1E9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
long long qmod(long long a, long long b, long long c) {
  long long res = 1;
  a %= c;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % c;
    a = a * a % c;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T, typename S>
void upmax(T& a, S b) {
  if (a < b) a = b;
}
template <typename T, typename S>
void upmin(T& a, S b) {
  if (a > b) a = b;
}
template <typename T>
void W(T m) {
  cout << m << endl;
}
void gettle() {
  while (1)
    ;
}
void getre() {
  int t = 0;
  t /= t;
}
const int N = 1 << 10;
int a[N + 4];
int b[N + 4];
int main() {
  int n, k, x;
  scanf("%d %d %d", &n, &k, &x);
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    a[t]++;
  }
  for (int i = 1; i <= k; i++) {
    int o = 1;
    for (int j = 0; j <= N; j++) {
      if (a[j]) {
        if (a[j] & 1) {
          if (o & 1) {
            b[j ^ x] += (a[j] / 2 + 1);
            b[j] += a[j] / 2;
          } else {
            b[j ^ x] += a[j] / 2;
            b[j] += (a[j] / 2 + 1);
          }
        } else {
          b[j ^ x] += a[j] / 2;
          b[j] += a[j] / 2;
        }
      }
      o += a[j];
    }
    for (int j = 0; j <= N; j++) {
      a[j] = b[j];
      b[j] = 0;
    }
  }
  int L = INF;
  int R = -INF;
  for (int i = 0; i <= N; i++) {
    if (a[i]) upmax(R, i), upmin(L, i);
  }
  printf("%d %d", R, L);
  return 0;
}
