#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, k, x;
    cin >> n >> k >> x;
    int count[1024] = {0};
    for (int i = 0; i < n; i++) {
      int z;
      cin >> z;
      count[z]++;
    }
    for (int i = 0; i < k; i++) {
      int sum = 0;
      int temp[1024] = {0};
      for (int j = 0; j < 1024; j++) {
        if (count[j] > 0) {
          int inc;
          if (count[j] % 2 == 0) {
            inc = count[j] / 2;
          } else {
            if (sum % 2 == 1) {
              inc = count[j] / 2;
            } else {
              inc = count[j] / 2 + 1;
            }
          }
          temp[j ^ x] += inc;
          sum += count[j];
          count[j] -= inc;
        }
      }
      for (int j = 0; j <= 1023; j++) {
        count[j] += temp[j];
      }
    }
    for (int i = 1023; i >= 0; i--) {
      if (count[i] > 0) {
        cout << i << " ";
        break;
      }
    }
    for (int i = 0; i <= 1023; i++) {
      if (count[i] > 0) {
        cout << i;
        break;
      }
    }
  }
  return 0;
}
