#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  scanf("%d%d%d", &n, &k, &x);
  int a[n + 1], freq[1500] = {0};
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    ++freq[a[i]];
  }
  while (k--) {
    int tot = 0, nw[1500] = {0};
    for (int i = 0; i < 1500; ++i) {
      if (!freq[i]) continue;
      if (!(tot % 2)) {
        nw[i] += freq[i] / 2;
        nw[i ^ x] += (freq[i] + 1) / 2;
      } else {
        nw[i] += (freq[i] + 1) / 2;
        nw[i ^ x] += freq[i] / 2;
      }
      tot += freq[i];
    }
    for (int i = 0; i < 1500; ++i) {
      freq[i] = nw[i];
    }
  }
  int mn = -1, mx = 0;
  for (int i = 0; i < 1500; ++i) {
    if (freq[i] && mn == -1) mn = i;
    if (freq[i]) mx = i;
  }
  printf("%d %d\n", mx, mn);
  return 0;
}
