#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
const int MAXN = 1033;
int n, k, x;
int ca[MAXN], cb[MAXN];
void go(int *fr, int *to) {
  int sum = 0, val, a, b;
  for (int i = 0; i < MAXN; i++) {
    val = i ^ x;
    a = fr[i] >> 1;
    b = fr[i] - a;
    if (sum & 1) swap(a, b);
    to[i] += a;
    to[val] += b;
    sum += fr[i];
  }
}
void solve() {
  cin >> n >> k >> x;
  int val;
  for (int i = 0; i < n; i++) {
    cin >> val;
    ca[val]++;
  }
  int *fr = ca, *to = cb;
  for (int i = 0; i < k; i++) {
    memset(to, 0, sizeof(int) * MAXN);
    go(fr, to);
    swap(fr, to);
  }
  int mx = 0, mn = INT_MAX;
  for (int i = 0; i < MAXN; i++) {
    if (fr[i]) {
      mx = max(mx, i);
      mn = min(mn, i);
    }
  }
  cout << mx << " " << mn;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
