#include <bits/stdc++.h>
using namespace std;
const int dx[9] = {0, 1, -1, 0, 0, -1, -1, 1, 1};
const int dy[9] = {0, 0, 0, -1, 1, -1, 1, -1, 1};
const double pi = acos(-1.0);
const int N = 19;
struct node {
  node *ch[2];
  int val;
  node() {
    ch[0] = ch[1] = NULL;
    val = 0;
  }
} * root;
int n, m, a[N + 10];
bool bo[1 << N];
void insert(int x) {
  node *p = root;
  for (int i = (N - 1); i >= 0; i--) {
    int temp = (x >> i) & 1;
    if (p->ch[temp] == NULL) p->ch[temp] = new node();
    p = p->ch[temp];
  }
  p->val = x;
}
int query(int x) {
  node *p = root;
  for (int i = (N - 1); i >= 0; i--) {
    int temp = (x >> i) & 1;
    if (p->ch[temp] == NULL)
      p = p->ch[temp ^ 1];
    else
      p = p->ch[temp];
  }
  return p->val;
}
int main() {
  root = new node();
  scanf("%d", &n), scanf("%d", &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    bo[x] = 1;
  }
  for (int i = 0; i <= (1 << N) - 1; i++)
    if (!bo[i]) insert(i);
  int now = 0;
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    now ^= x;
    printf("%d", now ^ query(now));
    puts("");
  }
  return 0;
}
