#include <bits/stdc++.h>
using namespace std;
const int INF = 1024;
int n, k, x, buc[INF + 1], tmp[INF + 1], p, ansmin = INF, ansmax;
int main() {
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 1; i <= n; ++i) {
    int t;
    scanf("%d", &t);
    ++buc[t];
  }
  memcpy(tmp, buc, sizeof(buc));
  for (int i = 1; i <= k; ++i) {
    p = 0;
    for (int j = 0; j <= INF; ++j) {
      if (buc[j]) {
        int t1 = j ^ x, t2 = (!p && buc[j] & 1) ? buc[j] / 2 + 1 : buc[j] / 2;
        tmp[j] -= t2;
        tmp[t1] += t2;
        p ^= (buc[j] & 1);
      }
    }
    memcpy(buc, tmp, sizeof(tmp));
  }
  for (int i = 0; i <= INF; ++i)
    if (buc[i]) {
      ansmin = min(ansmin, i);
      ansmax = max(ansmax, i);
    }
  printf("%d %d\n", ansmax, ansmin);
  return 0;
}
