#include <bits/stdc++.h>
using namespace std;
const int N = 3101010, M = 19;
struct data {
  int ch[2], siz, Max, end, num;
} trie[N];
int n, Q, a[N], ans, Xor = 0;
void build(int k, int dep) {
  if (dep == M) {
    trie[k].Max = 1;
    trie[k].end = 1;
    trie[k].num = k - (1 << (dep + 1));
    return;
  }
  build(k * 2, dep + 1);
  build(k * 2 + 1, dep + 1);
  trie[k].Max = trie[k * 2].Max + trie[k * 2 + 1].Max;
  trie[k].siz = trie[k * 2].siz + trie[k * 2 + 1].siz;
}
void insert(int x) {
  int now = 1;
  for (int i = M; i >= 0; i--)
    if (x & (1 << i))
      now = now * 2 + 1;
    else
      now *= 2;
  if (!trie[now].siz) trie[now].siz++;
}
int Mex(int k, int dep, int num) {
  if (trie[k].end) return num;
  int lson, rson;
  if (Xor & (1 << (dep - 1)))
    lson = k * 2 + 1;
  else
    lson = k * 2;
  rson = 4 * k + 1 - lson;
  if (trie[lson].siz < trie[lson].Max)
    return Mex(lson, dep - 1, num);
  else {
    return Mex(rson, dep - 1, num + (1 << (dep - 1)));
  }
}
void print(int k) {
  cout << k << ' ' << trie[k].siz << ' ' << trie[k].Max << endl;
  if (trie[k].end) return;
  print(k * 2);
  print(k * 2 + 1);
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    insert(a[i]);
  }
  build(1, -1);
  for (int i = 1, x; i <= Q; i++) {
    scanf("%d", &x);
    Xor ^= x;
    printf("%d\n", Mex(1, M + 1, 0));
  }
}
