#include <bits/stdc++.h>
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
using namespace std;
int n, m, x, ans;
vector<int> v;
int w[30];
struct node {
  int l = -1, r = -1;
  int val;
  int dep;
} tree[3000005];
int cnt = 0;
int base = 0;
int apow(int a, int b) {
  int s = 1;
  while (b) {
    if (b & 1) {
      s = s * a;
    }
    a = a * a;
    b >>= 1;
  }
  return s;
}
void insertt() {
  int p = 0;
  for (int i = 21; i >= 0; i--) {
    int c = w[i];
    tree[p].dep = i + 1;
    tree[p].val++;
    if (c == 0) {
      if (tree[p].l == -1) {
        tree[p].l = ++cnt;
      }
      p = tree[p].l;
    } else {
      if (tree[p].r == -1) {
        tree[p].r = ++cnt;
      }
      p = tree[p].r;
    }
  }
  tree[p].val++;
}
void solve() {
  int p = 0;
  for (int i = 21; i >= 0; i--) {
    int c = w[i];
    if (c == 0) {
      if (tree[p].l == -1) {
        return;
      }
      int v = tree[p].l;
      if (tree[v].val != apow(2, tree[v].dep)) {
        p = v;
        continue;
      }
      ans += apow(2, tree[p].dep - 1);
      if (tree[p].r == -1) {
        return;
      }
      p = tree[p].r;
      continue;
    }
    if (c == 1) {
      if (tree[p].r == -1) {
        return;
      }
      int v = tree[p].r;
      if (tree[v].val != apow(2, tree[v].dep)) {
        p = v;
        continue;
      }
      ans += apow(2, tree[p].dep - 1);
      if (tree[p].l == -1) {
        return;
      }
      p = tree[p].l;
      continue;
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < v.size(); i++) {
    for (int j = 21; j >= 0; j--) {
      w[j] = (v[i] >> j) & 1;
    }
    insertt();
  }
  while (m--) {
    scanf("%d", &x);
    base ^= x;
    for (int j = 21; j >= 0; j--) {
      w[j] = (base >> j) & 1;
    }
    ans = 0;
    solve();
    printf("%d\n", ans);
  }
  return 0;
}
