#include <bits/stdc++.h>
using namespace std;
int inf = 2147483647;
const long long ll = 9223372036854775807;
int A[100005] = {};
int main() {
  int a, b, c;
  while (cin >> a >> b >> c) {
    int B[2030] = {}, C[2334] = {};
    for (int i = 0; i < a; i++) {
      cin >> A[i];
      B[A[i]]++;
    }
    int now = 0, maxr = 0, minr = inf;
    for (int i = 0; i < b; i++) {
      now = 0;
      for (int j = 0; j < 1024; j++) {
        if (now % 2) {
          C[j] = (B[j]) / 2;
        } else {
          C[j] = (B[j] + 1) / 2;
        }
        now += B[j];
      }
      for (int j = 0; j < 1024; j++) {
        B[j] -= C[j];
        B[j ^ c] += C[j];
      }
    }
    for (int i = 0; i < 1024; i++) {
      if (B[i]) {
        minr = i;
        break;
      }
    }
    for (int i = 1024; i >= 0; i--) {
      if (B[i]) {
        maxr = i;
        break;
      }
    }
    cout << maxr << " " << minr << '\n';
  }
  return 0;
}
