#include <bits/stdc++.h>
using namespace std;
int a[1100], b[1100];
int main() {
  int i, j, n, k, x;
  cin >> n >> k >> x;
  int arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    a[arr[i]]++;
  }
  for (j = 0; j < k; j++) {
    int sum = 0;
    for (i = 0; i < 1100; i++) {
      if (a[i] > 0) {
        if (a[i] % 2 == 0) {
          int l = (i ^ x);
          b[l] += a[i] / 2;
          b[i] += a[i] / 2;
        } else {
          if (sum % 2 == 0) {
            int l = (i ^ x);
            b[l] += a[i] / 2 + 1;
            b[i] += a[i] / 2;
          } else {
            int l = (i ^ x);
            b[l] += a[i] / 2;
            b[i] += a[i] / 2 + 1;
          }
        }
        sum += a[i];
      }
    }
    for (i = 0; i < 1100; i++) {
      a[i] = b[i];
      b[i] = 0;
    }
  }
  int Min = INT_MAX;
  int Max = INT_MIN;
  for (i = 0; i < 1100; i++) {
    if (a[i] > 0) {
      Min = min(i, Min);
      Max = max(Max, i);
    }
  }
  cout << Max << " " << Min << endl;
  return 0;
}
