#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int a, freq[2][1025];
int main() {
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    freq[0][a]++;
  }
  int rIdx = 0;
  for (int i = 0; i < k; i++, rIdx = 1 - rIdx) {
    int tot = 0;
    memset(freq[1 - rIdx], 0, sizeof(freq[1 - rIdx]));
    for (int i = 0; i <= 1024; i++) {
      if (tot & 1) {
        int tmp = freq[rIdx][i] / 2;
        tot += freq[rIdx][i];
        freq[1 - rIdx][i ^ x] += tmp;
        freq[1 - rIdx][i] += (freq[rIdx][i] - tmp);
      } else {
        int tmp = freq[rIdx][i] / 2 + (freq[rIdx][i] % 2);
        tot += freq[rIdx][i];
        freq[1 - rIdx][i ^ x] += tmp;
        freq[1 - rIdx][i] += (freq[rIdx][i] - tmp);
      }
    }
  }
  int mn = 1025, mx = 0;
  for (int i = 0; i <= 1024; i++) {
    if (freq[rIdx][i] != 0) {
      mn = min(mn, i);
      mx = max(mx, i);
    }
  }
  printf("%d %d\n", mx, mn);
}
