#include <bits/stdc++.h>
using namespace std;
int n, q;
int sz, nxt[(1 << 20)][2], son[(1 << 20)], val[(1 << 20)];
bool vis[(1 << 20)];
void insert(int v, int add) {
  int x = 0;
  for (int i = 18; i >= 0; i--) {
    int c = (v >> i) & 1;
    if (!nxt[x][c]) nxt[x][c] = sz++;
    x = nxt[x][c];
    son[x] += add;
  }
  val[x] = v;
}
int query(int v) {
  int x = 0;
  for (int i = 18; i >= 0; i--) {
    int c = (v >> i) & 1;
    if (son[nxt[x][c]] == (1 << i))
      x = nxt[x][c ^ 1];
    else
      x = nxt[x][c];
  }
  return val[x];
}
int main() {
  scanf("%d %d", &n, &q);
  sz++;
  for (int i = 0; i < (1 << 19); i++) insert(i, 0);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (vis[x]) continue;
    insert(x, 1);
    vis[x] = 1;
  }
  int cur = 0, x;
  while (q--) {
    scanf("%d", &x);
    cur ^= x;
    printf("%d\n", query(cur) ^ cur);
  }
  return 0;
}
