#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
bool vis[N];
int trie[N * 20][2], sz;
void inser(int n) {
  int curr = 0;
  for (int i = 19; i >= 0; i--) {
    int dir = (n >> i) & 1;
    if (trie[curr][dir] == -1) trie[curr][dir] = ++sz;
    curr = trie[curr][dir];
  }
}
int query(int n) {
  int curr = 0, ans = 0;
  for (int i = 19; i >= 0; i--) {
    int dir = (n >> i) & 1;
    if (trie[curr][dir] != -1) {
      curr = trie[curr][dir];
    } else {
      ans += (1 << i);
      curr = trie[curr][1 ^ dir];
    }
  }
  return ans;
}
int main() {
  memset(trie, -1, sizeof(trie));
  int n, q;
  scanf("%d%d", &n, &q);
  while (n--) {
    int a;
    scanf("%d", &a);
    vis[a] = true;
  }
  for (int i = 0; i < N; i++)
    if (!vis[i]) inser(i);
  int xorval = 0;
  while (q--) {
    int x;
    scanf("%d", &x);
    xorval ^= x;
    printf("%d\n", query(xorval));
  }
  return 0;
}
