#include <bits/stdc++.h>
using namespace std;
long long z = 1;
int ch[600005 * 32][2], cnt, s[600005], siz[600005], vis[600005],
    v[600005 * 32];
void insert(int p, int val) {
  int i, c;
  for (i = 31; i >= 0; i--) {
    c = val >> i & 1;
    if (!ch[p][c]) ch[p][c] = ++cnt;
    p = ch[p][c];
    siz[p]++;
  }
  v[p] = val;
}
int query(int p, int val) {
  int i, c, a, b, ans = 0;
  for (i = 31; i >= 0; i--) {
    c = val >> i & 1;
    a = ch[p][c], b = ch[p][c ^ 1];
    if (!a) break;
    if (siz[a] == (1 << i)) {
      ans |= (1 << i);
      p = b;
    } else
      p = a;
  }
  return ans;
}
int main() {
  int i, j, n, m, las = 0;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &j);
    if (!vis[j]) vis[j] = 1, insert(0, j);
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &j);
    las ^= j;
    printf("%d\n", query(0, las));
  }
  return 0;
}
