#include <bits/stdc++.h>
namespace FASTIO {
char buf[1 << 21];
char *p1, *p2;
template <typename T>
inline void wt(T x, char c = '\n') {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  static char sta[sizeof(T) * 8];
  T top = 0;
  do {
    sta[top++] = x % 10;
    x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + '0');
  putchar(c);
}
template <typename T>
inline T rd() {
  T sum = 0, fl = 1;
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  for (; ch < '0' || ch > '9';
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    if (ch == '-')
      fl = -1;
    else if (ch == EOF)
      exit(0);
  for (; '0' <= ch && ch <= '9';
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    sum = sum * 10 + ch - '0';
  return sum * fl;
}
}  // namespace FASTIO
using namespace FASTIO;
int n, m;
int k;
int len;
std::vector<int> a;
struct node {
  node *son[2];
  int cnt;
  node() {
    son[0] = NULL;
    son[1] = NULL;
    cnt = 0;
  }
  ~node() {
    delete son[0];
    delete son[1];
  }
} root;
inline void insert(int x) {
  node *p = &root;
  for (int i = len; i >= 0; i--) {
    p->cnt++;
    const bool $ = (x & 1 << i) != 0;
    if (!p->son[$]) p->son[$] = new node();
    p = p->son[$];
  }
  p->cnt++;
  return;
}
inline int query() {
  const node *p = &root;
  int ans = 0;
  for (int i = len; p && i >= 0; i--) {
    const bool $ = (k & 1 << i) != 0;
    if (!p->son[$] || p->son[$]->cnt < 1 << i)
      p = p->son[$];
    else {
      p = p->son[!$];
      ans |= 1 << i;
    }
  }
  return ans;
}
int main() {
  n = rd<int>();
  m = rd<int>();
  a.resize(n);
  for (int &ele : a) ele = rd<int>();
  std::sort(a.begin(), a.end());
  a.erase(std::unique(a.begin(), a.end()), a.end());
  len = a.back();
  len = len ? log2(len) + 2 : 2;
  for (const int &A : a) insert(A);
  while (m--) {
    k ^= rd<int>();
    wt(query());
  }
  return 0;
}
