#include <bits/stdc++.h>
const int maxx = 300010;
const int maxn = 2;
using namespace std;
int Trie[31 * maxx][maxn];
int color[31 * maxx];
int vis[31 * maxx];
int k;
int n, m, a, b, ans;
void ini() {
  memset(Trie, 0, sizeof(Trie));
  memset(color, 0, sizeof(color));
  k = 0;
}
void insert(int w) {
  int p = 0;
  for (int i = 31; i >= 0; i--) {
    int c = (w >> i) & 1;
    if (!Trie[p][c]) {
      memset(Trie[k], 0, sizeof(Trie[k]));
      Trie[p][c] = ++k;
    }
    p = Trie[p][c];
  }
  color[p] = w;
}
int search(int w) {
  int p = 0;
  for (int i = 31; i >= 0; i--) {
    int c = (w >> i) & 1;
    if (Trie[p][c])
      p = Trie[p][c];
    else
      p = Trie[p][1 - c];
  }
  return color[p] ^ w;
}
int main() {
  ini();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    vis[a] = 1;
  }
  for (int i = 0; i <= 600000; i++) {
    if (!vis[i]) {
      insert(i);
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b);
    ans ^= b;
    printf("%d\n", search(ans));
  }
  return 0;
}
