#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 10;
int n, k, x;
int a[66][maxn];
int check(int t) {
  for (int i = 0; i < t; ++i) {
    int j;
    for (j = 0; j < n; ++j) {
      if (a[i][j] != a[t][j]) break;
    }
    if (j == n) return i;
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a[0][i];
  }
  int idx = k;
  sort(a[0], a[0] + n);
  for (int t = 1; t <= k; ++t) {
    for (int i = 0; i < n; ++i) {
      if (i & 1)
        a[t][i] = a[t - 1][i];
      else
        a[t][i] = a[t - 1][i] ^ x;
    }
    sort(a[t], a[t] + n);
    int st = check(t);
    if (st != -1) {
      int loooop = t - st;
      idx = st + (k - t) % loooop;
      break;
    }
  }
  int mx = -1, mn = 0x7fffffff;
  for (int i = 0; i < n; ++i) {
    mx = max(mx, a[idx][i]);
    mn = min(mn, a[idx][i]);
  }
  cout << mx << ' ' << mn;
  return 0;
}
