#include <bits/stdc++.h>
using namespace std;
int a[1 << 10], b[1 << 10];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, x;
  cin >> n >> k >> x;
  while (n--) {
    int t;
    cin >> t;
    a[t]++;
  }
  while (k--) {
    memset(b, 0, sizeof(b));
    bool ok = 1;
    for (int i = 0; i < (1 << 10); i++) {
      if (a[i]) {
        if (ok)
          b[i ^ x] += (a[i] + 1) / 2, b[i] += a[i] / 2;
        else
          b[i] += (a[i] + 1) / 2, b[i ^ x] += a[i] / 2;
        if (a[i] % 2) ok ^= 1;
      }
    }
    memcpy(a, b, sizeof(a));
  }
  int mn = (1 << 10), mx = 0;
  for (int i = 0; i < (1 << 10); i++)
    if (a[i]) mx = max(mx, i), mn = min(mn, i);
  cout << mx << " " << mn;
  return 0;
}
