#include <bits/stdc++.h>
using namespace std;
int ch[2101000][2], tot, siz[2210101];
void ins(int x) {
  int u = 0;
  for (int i = 19; i >= 0; i--) {
    int chi = x >> i & 1;
    if (!ch[u][chi]) ch[u][chi] = ++tot;
    u = ch[u][chi];
  }
}
void dfs(int u) {
  if (u) siz[u] = 1;
  if (ch[u][0]) dfs(ch[u][0]);
  if (ch[u][1]) dfs(ch[u][1]);
  siz[u] += siz[ch[u][1]] + siz[ch[u][0]];
}
int query(int x) {
  int u = 0, res = 0;
  for (int i = 19; i >= 0; i--) {
    int chi = x >> i & 1;
    if (siz[ch[u][chi]] != (1 << (i + 1)) - 1) {
      res |= chi << i;
      u = ch[u][chi];
    } else {
      res |= (chi ^ 1) << i;
      u = ch[u][chi ^ 1];
    }
  }
  return res;
}
int main() {
  int n, QAQ;
  scanf("%d%d", &n, &QAQ);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    ins(x);
  }
  dfs(0);
  int tmp = 0;
  while (QAQ--) {
    int res = 0, x;
    scanf("%d", &x);
    tmp ^= x;
    res = query(tmp);
    printf("%d\n", res ^ tmp);
  }
}
