#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int mod = 1000000007;
const double PI = acos(-1.0);
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int n, m;
long long ans;
int a[100005];
int b[2000];
int c[2000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, x;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    b[num]++;
  }
  for (int i = 0; i < k; i++) {
    int cnt = 1;
    memset(c, 0, sizeof(c));
    for (int j = 0; j <= 1111; j++) {
      if (b[j]) {
        if ((cnt & 1)) {
          c[j ^ x] += (b[j] + 1) / 2;
          c[j] += b[j] / 2;
        } else {
          c[j ^ x] += b[j] / 2;
          c[j] += (b[j] + 1) / 2;
        }
        cnt += b[j];
      }
    }
    for (int j = 0; j <= 1111; j++) b[j] = c[j];
  }
  int ans1 = 0, ans2 = 0x3f3f3f3f;
  for (int j = 0; j <= 1111; j++)
    if (b[j]) {
      ans1 = max(ans1, j);
      ans2 = min(ans2, j);
    }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
