#include <bits/stdc++.h>
using namespace std;
const int MAX_A = 1024;
int acs[2][MAX_A];
int main() {
  int n, k, x;
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    acs[0][ai]++;
  }
  int cur = 0, nxt = 1;
  for (int i = 0; i < k; i++) {
    memset(acs[nxt], 0, sizeof(acs[nxt]));
    int sum = 0;
    for (int a = 0; a < MAX_A; a++) {
      int c = (sum & 1) ? acs[cur][a] / 2 : (acs[cur][a] + 1) / 2;
      acs[nxt][a ^ x] += c;
      acs[nxt][a] += acs[cur][a] - c;
      sum += acs[cur][a];
    }
    swap(cur, nxt);
  }
  int mina = -1, maxa = -1;
  for (int a = 0; a < MAX_A; a++)
    if (acs[cur][a] > 0) {
      if (mina < 0) mina = a;
      maxa = a;
    }
  printf("%d %d\n", maxa, mina);
  return 0;
}
