#include <bits/stdc++.h>
using namespace std;
int n, t, m;
const int maxn = 6e5;
struct node {
  int val;
  node *next[2];
  node() {
    val = 0;
    memset(next, 0, sizeof(next));
  }
};
class trie {
 public:
  node *rt;
  trie() { rt = new node; }
  void update(int n) {
    bitset<33> bit(n);
    node *cur = rt;
    for (int i = 32; i >= 0; --i) {
      int temp = bit[i];
      if (!cur->next[temp]) {
        node *lat = new node();
        cur->next[temp] = lat;
        cur = lat;
      } else
        cur = cur->next[temp];
    }
    cur->val = n;
  }
  int query(int k) {
    bitset<33> bit(k);
    node *cur = rt;
    for (int i = 32; i >= 0; --i) {
      int temp = bit[i];
      if (cur->next[temp])
        cur = cur->next[temp];
      else
        cur = cur->next[temp ^ 1];
    }
    return cur->val ^ k;
  }
  void dfs(node *p) {
    for (int i = 0; i < 2; i++)
      if (p->next[i]) {
        dfs(p->next[i]);
        delete p->next[i];
      }
  }
  void del() { dfs(rt); }
};
int a[maxn];
int vis[maxn * 2];
int main() {
  cin >> n >> m;
  trie tr;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    vis[a[i]] = 1;
  }
  for (int i = 0; i <= 6e5; i++) {
    if (vis[i] == 0) tr.update(i);
  }
  int tmp = 0;
  int x;
  while (m--) {
    cin >> x;
    tmp = tmp ^ x;
    int ans = tr.query(tmp);
    cout << ans << endl;
  }
  tr.del();
  return 0;
}
