#include <bits/stdc++.h>
using namespace std;
typedef struct tree {
  tree *nex[2];
  long long int v;
  long long int val;
} tree;
tree root;
void creat(char *str, int va) {
  int len = strlen(str);
  tree *p = &root, *q;
  for (int i = 0; i < len; i++) {
    int id = str[i] - '0';
    if (p->nex[id] == NULL) {
      q = (tree *)malloc(sizeof(root));
      q->v = 1;
      for (int j = 0; j < 2; j++) {
        q->nex[j] = NULL;
      }
      p->nex[id] = q;
    } else {
      p->nex[id]->v++;
    }
    p = p->nex[id];
    if (i == len - 1) {
      p->val = va;
    }
  }
}
void find(char *str, long long int query) {
  long long int len = strlen(str);
  tree *p = &root;
  for (long long int i = 0; i < len; i++) {
    long long int id = str[i] - '0';
    if (p->nex[id] != NULL)
      p = p->nex[id];
    else
      p = p->nex[1 - id];
  }
  printf("%lld\n", p->val ^ query);
}
int main() {
  long long int n, q;
  while (~scanf("%lld%lld", &n, &q)) {
    for (long long int i = 0; i < 2; i++) {
      root.nex[i] = NULL;
      root.v = 0;
      root.val = 0;
    }
    map<long long int, long long int> s;
    for (long long int i = 1; i <= n; i++) {
      long long int x;
      scanf("%lld", &x);
      if (s[x] == 0) {
        s[x] = 1;
      }
    }
    for (long long int i = 0; i <= 600000; i++) {
      if (s[i] == 0) {
        char ss[25];
        long long int x = i;
        ss[21] = '\0';
        for (int j = 20; j >= 0; j--) {
          if (x) {
            ss[j] = x % 2 + '0';
            x /= 2;
          } else
            ss[j] = '0';
        }
        creat(ss, i);
      }
    }
    long long int temp = 0;
    while (q--) {
      long long int x;
      scanf("%lld", &x);
      temp ^= x;
      x = temp;
      char ss[25];
      ss[21] = '\0';
      for (int j = 20; j >= 0; j--) {
        if (x) {
          ss[j] = x % 2 + '0';
          x /= 2;
        } else {
          ss[j] = '0';
        }
      }
      find(ss, temp);
    }
  }
}
