#include <bits/stdc++.h>
using namespace std;
int trie[8888888];
bool used[300050];
const int sz = 20;
void update(int bit, int node, int num) {
  ++trie[node];
  if (bit == 0) {
    return;
  }
  if (1 << (bit - 1) & num) {
    update(bit - 1, node << 1 | 1, num);
  } else {
    update(bit - 1, node << 1, num);
  }
}
int get(int bit, int node, int q, int ans) {
  if (bit == 0) {
    return ans;
  }
  if (1 << (bit - 1) & q) {
    if (trie[node << 1 | 1] < 1 << (bit - 1)) {
      return get(bit - 1, node << 1 | 1, q, ans);
    } else {
      return get(bit - 1, node << 1, q, ans + (1 << (bit - 1)));
    }
  } else {
    if (trie[node << 1] < 1 << (bit - 1)) {
      return get(bit - 1, node << 1, q, ans);
    } else {
      return get(bit - 1, node << 1 | 1, q, ans + (1 << (bit - 1)));
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int m;
  cin >> m;
  for (int i = 0; i < n; ++i) {
    int aux;
    cin >> aux;
    if (used[aux]) continue;
    used[aux] = true;
    update(sz, 1, aux);
  }
  int q = 0;
  for (int i = 0; i < m; ++i) {
    int aux;
    cin >> aux;
    q ^= aux;
    cout << get(sz, 1, q, 0) << '\n';
  }
  return 0;
}
