#include <bits/stdc++.h>
using namespace std;
const int mxn = 3e5 + 100;
int cnt[30 * mxn], son[30 * mxn][2], rev, sz = 1, n, q;
void add(int x) {
  for (int i = 20, node = 1; i >= 0; --i) {
    if (!son[node][x >> i & 1]) son[node][x >> i & 1] = ++sz;
    node = son[node][x >> i & 1], ++cnt[node];
  }
}
bool exist(int x) {
  for (int i = 20, node = 1; i >= 0; --i) {
    if (!son[node][x >> i & 1]) return false;
    node = son[node][x >> i & 1];
  }
  return true;
}
int mex() {
  int ret = 0;
  for (int i = 20, node = 1; i >= 0; --i) {
    int bit = rev >> i & 1, c = 1 << i;
    if (bit) {
      if (cnt[son[node][1]] == c)
        node = son[node][0], ret |= c;
      else
        node = son[node][1];
    } else {
      if (cnt[son[node][0]] == c)
        node = son[node][1], ret |= c;
      else
        node = son[node][0];
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    if (!exist(x)) add(x);
  }
  for (int i = 1, x; i <= q; ++i) {
    scanf("%d", &x), rev ^= x;
    printf("%d\n", mex());
  }
}
