#include <bits/stdc++.h>
using namespace std;
const int N = 2050;
int xo[N];
int q[N];
int temp[N];
int main() {
  int n, k, x;
  scanf("%d %d %d", &n, &k, &x);
  for (int i = 0; i < N; i++) {
    xo[i] = i ^ x;
    temp[i] = 0;
    q[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    q[a]++;
  }
  while (k--) {
    int last = 0;
    for (int i = 0; i < N; i++) {
      int p = q[i];
      if (p == 0) continue;
      int val = 0;
      if (last % 2 == 0) {
        val = (p + 1) / 2;
      } else
        val = p / 2;
      temp[xo[i]] += val;
      q[i] -= val;
      last += p;
    }
    for (int i = 0; i < N; i++) {
      q[i] += temp[i];
      temp[i] = 0;
    }
  }
  int mini = 1791791791, maxi = -1791791791;
  for (int i = 0; i < N; i++) {
    if (q[i] != 0) {
      mini = min(mini, i);
      maxi = max(maxi, i);
    }
  }
  printf("%d %d\n", maxi, mini);
  return 0;
}
