#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 3e5 + 10;
const int N = 1002;
const long long mod = 998244353;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
int tr[MAXN << 4][2], val[MAXN << 4], sz[MAXN << 4], a[MAXN], tot, s;
void ins(int x) {
  int p = 0;
  for (int i = 20; i >= 0; --i) {
    int v = (x >> i) & 1;
    if (!tr[p][v]) tr[p][v] = ++tot;
    p = tr[p][v];
    ++sz[p];
  }
  val[p] = x;
}
int query(int x) {
  int p = 0, ans = 0;
  for (int i = 20; i >= 0; --i) {
    int v = (x >> i) & 1;
    if (!tr[p][v])
      return ans;
    else if (sz[tr[p][v]] < 1 << i)
      p = tr[p][v];
    else {
      ans += 1 << i;
      if (!tr[p][v ^ 1]) return ans;
      p = tr[p][v ^ 1];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    ++a[x];
  }
  for (int i = 0; i < MAXN; ++i)
    if (a[i]) ins(i);
  while (m--) {
    int t;
    cin >> t;
    s ^= t;
    cout << query(s) << '\n';
  }
}
