#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k, x, y, counter = 0, cycle, sz;
vector<int> v;
map<vector<int>, int> vis;
map<int, vector<int> > state;
map<vector<int>, int> came;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> y, v.push_back(y);
  sort(v.begin(), v.end());
  came[v] = 1;
  state[counter] = v;
  vis[v] = counter++;
  for (int i = 0; i < min(k, 100); i++) {
    for (int j = 0; j < n; j++)
      if (j % 2 == 0) v[j] ^= x;
    sort(v.begin(), v.end());
    if (came[v]) {
      int s = vis[v];
      int e = k - i - 1;
      int mod = counter - s;
      cout << state[e % mod + s][n - 1] << " " << state[e % mod + s][0];
      return 0;
    }
    came[v] = 1;
    state[counter] = v;
    vis[v] = counter++;
  }
  cout << v[n - 1] << " " << v[0];
  return 0;
}
