#include <bits/stdc++.h>
using namespace std;
const int Bits = 18;
struct Trie {
  Trie *son[2];
  int cnt;
  Trie() {
    memset(son, 0, sizeof(son));
    cnt = 0;
  }
  void bag(int x, int freq) {
    Trie *root = this;
    for (int i = Bits; i >= 0; --i) {
      bool dir = (1 << i) & x;
      if (root->son[dir] == NULL) root->son[dir] = new Trie();
      root = root->son[dir];
      root->cnt += freq;
    }
  }
  int query(int x, int k) {
    Trie *root(this);
    ++k;
    int rez = 0;
    for (int i = Bits; i >= 0; --i) {
      bool bit_k = k & (1 << i), bit_x = x & (1 << i);
      if (bit_k) {
        if (root->son[bit_x] != NULL) rez += root->son[bit_x]->cnt;
        if (!root->son[bit_x ^ 1]) break;
        root = root->son[bit_x ^ 1];
      } else {
        if (root->son[bit_x] == NULL) break;
        root = root->son[bit_x];
      }
    }
    return rez;
  }
};
const int N = 3e5 + 2;
int n, m;
set<int> ar;
Trie *T = new Trie;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ar.insert(x);
  }
  for (auto it : ar) T->bag(it, 1);
  int cXor = 0;
  for (int i = 0; i < m; ++i) {
    int x;
    scanf("%d", &x);
    cXor ^= x;
    int st = 0, dr = (1 << 19), ans = -1;
    while (st <= dr) {
      int mij = (st + dr) >> 1;
      if (T->query(cXor, mij) == mij + 1) {
        st = mij + 1;
        ans = mij;
      } else
        dr = mij - 1;
    }
    printf("%d\n", ans + 1);
  }
}
