#include <bits/stdc++.h>
using namespace std;
void CyBerForCe() {
  long long n, k, x;
  cin >> n >> k >> x;
  vector<long long> v, u1, u2;
  long long f[1024] = {0}, temp[1024];
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    v.push_back(a);
    f[a]++;
  }
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < 1024; j++) temp[j] = 0;
    long long c = 0;
    for (long long j = 0; j < 1024; j++) {
      temp[j] += ((f[j] + c) / 2);
      temp[j ^ x] += ((f[j] + 1 - c) / 2);
      c = (c + f[j]) & 1;
    }
    for (long long j = 0; j < 1024; j++) f[j] = temp[j];
  }
  long long mi = 1026, ma = -1;
  for (long long i = 0; i < 1024; i++) {
    if (f[i] > 0) {
      mi = min(mi, i);
      ma = max(ma, i);
    }
  }
  cout << ma << " " << mi << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  CyBerForCe();
  return 0;
}
