#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 19;
int vis[1 << N];
struct trie {
  trie* bit[2];
  int cnt;
};
trie* head;
void insert(int val) {
  trie* tmp = head;
  for (int i = 19; i >= 0; i--) {
    int b = (val & (1ll << i) ? 1 : 0);
    if (tmp->bit[b] == NULL) {
      tmp->bit[b] = new trie();
    }
    tmp = tmp->bit[b];
    tmp->cnt++;
  }
}
void remove(int val) {
  trie* tmp = head;
  for (int i = 19; i >= 0; i--) {
    int b = (val & (1ll << i) ? 1 : 0);
    tmp = tmp->bit[b];
    tmp->cnt--;
  }
}
int mex(int val) {
  trie* tmp = head;
  int ans = 0;
  for (int i = 19; i >= 0; i--) {
    int b = (val & (1ll << i) ? 1 : 0);
    if (tmp->bit[b]) {
      tmp = tmp->bit[b];
    } else {
      ans += (1ll << i);
      tmp = tmp->bit[b ^ 1];
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  head = new trie();
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vis[x] = 1;
  }
  for (int i = 0; i < (1 << N); i++) {
    if (!vis[i]) {
      insert(i);
    }
  }
  int cur_xor = 0, x = 0;
  for (int i = 0; i < q; i++) {
    cin >> x;
    cur_xor ^= x;
    cout << mex(cur_xor) << "\n";
  }
  return 0;
}
