#include <bits/stdc++.h>
using namespace std;
template <class T1>
T1 GCD(T1 A, T1 B) {
  if (B == 0)
    return A;
  else
    return GCD(B, A % B);
}
template <class T2>
T2 mulmod(T2 a, T2 b) {
  T2 x = 0, y = a % 1000000007;
  while (b) {
    if (b % 2 == 1) {
      x = (x + y) % 1000000007;
    }
    y = (2 * y) % 1000000007;
    b = b / 2;
  }
  return x % 1000000007;
}
template <class T3>
T3 power(T3 a, T3 b) {
  T3 x = 1, y = a % 1000000007;
  while (b) {
    if (b % 2 == 1) {
      x = mulmod(x, y) % 1000000007;
    }
    y = mulmod(y, y) % 1000000007;
    b = b / 2;
  }
  return x % 1000000007;
}
template <class T4>
bool cmp(T4 x, T4 y) {
  return x > y ? 1 : 0;
}
int n;
int k;
int arr[100001];
vector<int> freq(1028, 0);
int x;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> x;
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    freq[temp]++;
  }
  for (int i = 1; i <= k; i++) {
    vector<int> temp_freq(1028, 0);
    int cnt = 1;
    for (int j = 0; j <= 1023; j++) {
      if (freq[j] != 0) {
        if (freq[j] % 2 == 0) {
          temp = j ^ x;
          temp_freq[temp] += (freq[j] / 2);
          temp_freq[j] += (freq[j] / 2);
        } else {
          temp = j ^ x;
          if (cnt % 2 == 0) {
            temp_freq[temp] += ((freq[j] / 2));
            temp_freq[j] += ((freq[j] / 2) + 1);
          } else {
            temp_freq[temp] += ((freq[j] / 2) + 1);
            temp_freq[j] += ((freq[j] / 2));
          }
        }
        cnt += freq[j];
      }
    }
    freq = temp_freq;
  }
  for (temp = 1023; temp >= 0; temp--)
    if (freq[temp] != 0) {
      cout << temp << " ";
      break;
    }
  for (temp = 0; temp <= 1023; temp++) {
    if (freq[temp] != 0) {
      cout << temp;
      break;
    }
  }
  return 0;
}
