#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> F(1025);
  int N, K, X;
  cin >> N >> K >> X;
  int mi = 100000, ma = 0;
  for (int i = 0; i < N; ++i) {
    int n;
    cin >> n;
    F[n]++;
  }
  for (int i = 0; i < K; ++i) {
    int id = 0;
    vector<int> F2(1025);
    for (int k = 0; k < F.size(); ++k) {
      if (F[k] == 0) continue;
      int v = F[k];
      int x = ((F[k] + (id % 2 == 0)) / 2);
      int nx = F[k] - x;
      int nk = k ^ X;
      F2[nk] += x;
      F2[k] += nx;
      id += v;
    }
    F = F2;
  }
  for (int k = 0; k < F.size(); ++k) {
    if (!F[k]) continue;
    mi = min(mi, k);
    ma = max(ma, k);
  }
  cout << ma << " " << mi << endl;
  return 0;
}
