#include <bits/stdc++.h>
using namespace std;
struct less_key {
  bool operator()(pair<int64_t, int64_t> p1, pair<int64_t, int64_t> p2) {
    return (p1.first < p2.first) || (p1.second < p2.second);
  }
};
struct pair_hash {
  std::size_t operator()(const pair<int64_t, int64_t>& k) const {
    return static_cast<size_t>(k.first ^ k.second);
  }
};
const int64_t mod = 100000000007ll;
const int64_t inf = 10000000000000007ll;
int64_t n, k, x;
int64_t a[100005];
int64_t b[1024];
int64_t c[1024];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> x;
  for (int64_t i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  for (int64_t i = 0; i < k; i++) {
    int64_t s = 0;
    memcpy(c, b, sizeof(int64_t) * 1024);
    for (int64_t j = 0; j <= 1023; j++) {
      if (!b[j]) {
        continue;
      }
      int64_t q = b[j] - (s % 2);
      int64_t t = q / 2 + q % 2;
      s += b[j];
      c[j] -= t;
      c[j ^ x] += t;
    }
    memcpy(b, c, sizeof(int64_t) * 1024);
  }
  int64_t rmin = 1024;
  int64_t rmax = -1;
  for (int64_t j = 0; j <= 1023; j++) {
    if (b[j]) {
      if (j < rmin) {
        rmin = j;
      }
      if (j > rmax) {
        rmax = j;
      }
    }
  }
  cout << rmax << " " << rmin;
  return 0;
}
