#include <bits/stdc++.h>
using namespace std;
int bits[25], a[300007], cnt = 0, opt = 0;
inline int in() {
  int W = 1, X = 0;
  char Ch = 0;
  while (!isdigit(Ch)) {
    if (Ch == '-') W = -1;
    Ch = getchar();
  }
  while (isdigit(Ch)) X = (X << 3) + (X << 1) + (Ch ^ '0'), Ch = getchar();
  return X * W;
}
inline void out(int M, char *s) {
  if (M < 0) putchar('-'), M = -M;
  if (M > 9) out(M / 10, "");
  putchar(M % 10 + '0');
  printf(s);
  return;
}
inline void getbits() {
  bits[0] = 1;
  for (register int i = 1; i <= 19; i++) bits[i] = bits[i - 1] << 1;
  return;
}
struct Trie {
  int s[1 << 24];
  inline void build() {
    memset(s, 0, sizeof(s));
    opt = 0;
    getbits();
  }
  inline void add(int cur, int dep, int x) {
    s[cur]++;
    if (dep < 0) return;
    bool tmp = bits[dep] & x;
    int Nxt = (cur << 1) | tmp;
    add(Nxt, dep - 1, x);
  }
  inline int query(int cur, int dep, int num) {
    if (dep < 0) return num;
    bool tmp = bits[dep] & opt;
    int Nxt = (cur << 1) | tmp;
    if (s[Nxt] < bits[dep]) return query(Nxt, dep - 1, num);
    return query((Nxt ^ 1), dep - 1, num + bits[dep]);
  }
} A;
int main() {
  int n, q;
  n = in(), q = in();
  A.build();
  for (register int i = 1; i <= n; i++) a[i] = in();
  sort(a + 1, a + n + 1);
  n = unique(a + 1, a + n + 1) - a - 1;
  while (n) A.add(1, 19, a[n--]);
  while (q--) {
    opt ^= in();
    out(A.query(1, 19, 0), "\n");
  }
}
