#include <bits/stdc++.h>
using namespace std;
inline int sa(long long &x) { return scanf("%lld", &x); }
inline void pu(long long x) { printf("%lld", x); }
inline int sa(int &x) { return scanf("%d", &x); }
inline int sa(double &x) { return scanf("%lf", &x); }
inline void pu(int x) { printf("%d", x); }
inline void pu(double x) { printf("%g", x); }
template <class T>
inline void pt(T x) {
  putchar(' ');
  pu(x);
}
template <class T>
inline void puln(T x) {
  pu(x);
  putchar('\n');
}
template <class T>
inline int sad(T &x, T &y) {
  sa(x);
  sa(y);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int inf = 0x3f3f3f3f;
const int INF = 0x7fffffff;
const int maxn = 4001000;
bool rev[maxn];
int cnt[maxn], ch[maxn][2], rt, tot;
int build(int ddp) {
  int now = tot++;
  if (ddp >= 0) {
    ch[now][0] = build(ddp - 1);
    ch[now][1] = build(ddp - 1);
  }
  return now;
}
void up(int o) { cnt[o] = min(cnt[(ch[o][0])], cnt[(ch[o][1])]); }
void insert(int o, int ddp, int x) {
  if (ddp == -1) {
    cnt[o]++;
    return;
  }
  int t = (x >> ddp & 1);
  insert(ch[o][t], ddp - 1, x);
  up(o);
}
int n, m, x;
int main() {
  rt = build(19);
  sa(n);
  sa(m);
  for (int i = 1; i <= (n); i++) {
    scanf("%d", &x);
    insert(rt, 19, x);
  }
  while (m--) {
    scanf("%d", &x);
    for (int i = 19; i >= 0; i--)
      if (x >> i & 1) rev[i] ^= 1;
    int ans = 0, now = rt;
    for (int i = 19; i >= 0; --i) {
      if (rev[i]) {
        if (cnt[ch[now][1]] == 0)
          now = ch[now][1];
        else {
          now = ch[now][0];
          ans += (1 << i);
        }
      } else {
        if (cnt[ch[now][0]] == 0)
          now = ch[now][0];
        else {
          now = ch[now][1];
          ans += (1 << i);
        }
      }
    }
    printf("%d\n", ans);
  }
}
