#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int cuantos[2000];
int nextcuantos[2000];
int main() {
  cin >> n >> k >> x;
  for (int i = 1; i <= n; i++) {
    int y;
    cin >> y;
    cuantos[y]++;
  }
  int tope = 1 << 10;
  for (int paso = 0; paso < k; paso++) {
    int vistos = 0;
    for (int y = 0; y < tope; y++) {
      int c = cuantos[y];
      if (c) {
        if (vistos & 1) {
          nextcuantos[y ^ x] += c >> 1;
          nextcuantos[y] += (c + 1) >> 1;
        } else {
          nextcuantos[y ^ x] += (c + 1) >> 1;
          nextcuantos[y] += c >> 1;
        }
        vistos += c;
      }
    }
    int *py = &(cuantos[0]);
    int *nextpy = &(nextcuantos[0]);
    for (int y = 0; y < tope; y++, py++, nextpy++) {
      *py = *nextpy;
      *nextpy = 0;
    }
  }
  int ymin = 0;
  while (cuantos[ymin] == 0) ymin++;
  int ymax = tope - 1;
  while (cuantos[ymax] == 0) ymax--;
  cout << ymax << " " << ymin << endl;
}
