#include <bits/stdc++.h>
using namespace std;
inline void err(istringstream *iss) {}
template <typename T, typename... Args>
void err(istringstream *iss, const T &$val, const Args &...args) {
  string $name;
  *iss >> $name;
  if ($name.back() == ',') $name.pop_back();
  cout << $name << " = " << $val << "; ", err(iss, args...);
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int n, m, K, T, Q, cn;
struct Trie {
  static const int maxNode = (1 << 19) * 20, CHARSET = 2;
  int end, wordCnt, nxt[maxNode][CHARSET];
  char ch[maxNode];
  void init() {
    memset(nxt, -1, sizeof(nxt));
    end = 1, wordCnt = 0;
  }
  void add(const bool *s, int len) {
    int p = 0;
    for (int i = 0; i < len; i++) {
      int &nxtp = nxt[p][*s];
      if (nxtp == -1) {
        nxtp = end++;
        ch[nxtp] = *s;
      }
      p = nxtp, s++;
    }
  }
  int lower_bound_lexi_sameLen(const bool *s, int len) {
    int ret = 0;
    for (int i = 0, p = 0; i < len; i++, s++) {
      bool os = nxt[p][*s] == -1 ? !*s : *s;
      p = nxt[p][os];
      if (os) ret |= 1 << (len - 1 - i);
    }
    return ret;
  }
};
bool s[22];
Trie t;
int a[300005], os, x;
bitset<1 << 20 | 3> vstd;
int main() {
  cin.tie(NULL);
  t.init();
  scanf("%d%d", &n, &Q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]), vstd[a[i]] = 1;
  }
  for (int i = 0; i < 1 << 19; i++) {
    if (vstd[i]) continue;
    for (int j = 0; j < 19; j++) {
      s[18 - j] = ((i >> j) & 1);
    }
    t.add(s, 19);
  }
  while (Q--) {
    scanf("%d", &x);
    os ^= x;
    for (int j = 0; j < 19; j++) {
      s[18 - j] = ((os >> j) & 1);
    }
    printf("%d\n", os ^ t.lower_bound_lexi_sameLen(s, 19));
  }
  return 0;
}
