#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, m;
int px[25];
bool mark[N];
struct node {
  node* child[2];
  int tot;
  node() {
    for (int i = 0; i < 2; ++i) child[i] = NULL;
    tot = 0;
  }
};
typedef node* pnode;
pnode root;
int get(int x, int k) { return (x >> k) & 1; }
pnode buildTree(int i) {
  if (i < 0) return NULL;
  pnode x = new node();
  for (int k = 0; k < 2; ++k) x->child[k] = buildTree(i - 1);
  return x;
}
void add(int x, int i = 19, pnode p = root) {
  if (i == 0) {
    p->tot++;
    return;
  }
  int bit = get(x, i - 1);
  add(x, i - 1, p->child[bit]);
  p->tot = p->child[0]->tot + p->child[1]->tot;
}
void query(int prev) {
  int Answer = 0;
  pnode p = root;
  for (int i = 18; i >= 0; --i) {
    int bit = get(prev, i), nxt;
    if (!bit) {
      if (p->child[0]->tot == px[i])
        nxt = 1;
      else
        nxt = 0;
      p = p->child[nxt];
      Answer += px[i] * nxt;
      continue;
    }
    if (p->child[1]->tot == px[i])
      nxt = 0;
    else
      nxt = 1;
    p = p->child[nxt];
    Answer += px[i] * (nxt ^ 1);
  }
  cout << Answer << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  root = new node();
  root = buildTree(19);
  for (int i = 1, x; i <= n; ++i) {
    cin >> x;
    if (!mark[x]) add(x);
    mark[x] = true;
  }
  px[0] = 1;
  for (int i = 1; i <= 20; ++i) px[i] = px[i - 1] * 2;
  int prev = 0, x;
  while (m--) {
    cin >> x;
    prev ^= x;
    query(prev);
  }
}
