#include <bits/stdc++.h>
using namespace std;
string s[11000];
int n, k, x, a[110000];
string str;
struct node {
  int x, y;
} p[110000];
int main() {
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  p[0].x = a[0], p[0].y = a[n - 1];
  int indx = 0, y = -1;
  for (int i = 0; i < n; i++) str += a[i];
  s[indx] = str;
  while (1) {
    for (int i = 0; i < n; i += 2) a[i] ^= x;
    sort(a, a + n);
    str.clear();
    for (int i = 0; i < n; i++) str += a[i];
    int flag = 1;
    for (int i = 0; i < indx; i++) {
      if (s[i] == str) {
        y = i;
        flag = 0;
        break;
      }
    }
    if (!flag)
      break;
    else {
      s[++indx] = str;
      p[indx].x = a[0], p[indx].y = a[n - 1];
    }
  }
  if (k < y)
    printf("%d %d\n", p[k].y, p[k].x);
  else {
    k -= y;
    printf("%d %d\n", p[(k % (indx - y + 1)) + y].y,
           p[(k % (indx - y + 1)) + y].x);
  }
  return 0;
}
