#include <bits/stdc++.h>
using namespace std;
int ch[3000005][2];
int v[3000005];
map<int, int> mp;
int sz;
void inser(int x) {
  int u = 0;
  for (int i = 20; i >= 0; i--) {
    int c = x >> i & 1;
    if (!ch[u][c]) {
      memset(ch[sz], 0, sizeof(ch[sz]));
      v[sz] = 0;
      ch[u][c] = sz++;
    }
    u = ch[u][c];
  }
  v[u] = x;
}
int query(int y) {
  int u = 0;
  for (int i = 20; i >= 0; i--) {
    int c = y >> i & 1;
    if (ch[u][c])
      u = ch[u][c];
    else
      u = ch[u][c ^ 1];
  }
  return v[u] ^ y;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  sz = 1;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    mp[x] = 1;
  }
  for (int i = 0; i <= 600005; i++) {
    if (mp[i] == 0) inser(i);
  }
  int yi = 0;
  for (int i = 1; i <= m; i++) {
    int y;
    scanf("%d", &y);
    yi ^= y;
    printf("%d\n", query(yi));
  }
  return 0;
}
