#include <bits/stdc++.h>
using namespace std;
int n, k, x, nums[100100];
int cont[1100], aux[1100];
int main() {
  scanf("%d %d %d", &n, &k, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &nums[i]);
    cont[nums[i]]++;
  }
  for (int i = 0; i < k; i++) {
    bool ceil = true;
    for (int j = 0; j < 1100; j++)
      if (cont[j] > 0) {
        int to_transfer = (cont[j] + ceil) / 2;
        aux[j ^ x] += to_transfer;
        aux[j] += cont[j] - to_transfer;
        if (cont[j] % 2 != 0) ceil = !ceil;
      }
    for (int j = 0; j < 1100; j++) {
      cont[j] = aux[j];
      aux[j] = 0;
    }
  }
  int mini, maxi;
  for (int i = 0; i < 1100; i++)
    if (cont[i] > 0) {
      mini = i;
      break;
    }
  for (int i = 1099; i >= 0; i--)
    if (cont[i] > 0) {
      maxi = i;
      break;
    }
  printf("%d %d\n", maxi, mini);
  return 0;
}
