#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
long long MAX = 1e18 + 7;
long long mod = 1e9 + 7;
long long grev[200001];
vector<long long> gr[100005];
set<long long> a;
vector<long long> b;
class trie {
 public:
  trie *child[2];
  trie() { child[0] = child[1] = NULL; }
};
void insert(trie *root, long long x) {
  for (long long i = int(20); i >= int(0); i--) {
    long long bit = ((x >> i) & 1);
    if (root->child[bit] == NULL) {
      root->child[bit] = new trie();
    }
    root = root->child[bit];
  }
}
long long minxor(trie *root, long long x) {
  long long res = 0;
  for (long long i = int(20); i >= int(0); i--) {
    long long bit = ((x >> i) & 1);
    if (root->child[bit] == NULL) {
      res += (1ll << i);
      root = root->child[!bit];
    } else {
      root = root->child[bit];
    }
  }
  return res;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  trie *root = new trie();
  for (long long i = int(0); i < int(n); i++) {
    long long x;
    cin >> x;
    a.insert(x);
  }
  b.clear();
  for (long long i = int(0); i < int(1 << 20); i++) {
    if (a.find(i) == a.end()) b.push_back(i);
  }
  for (long long x : b) {
    insert(root, x);
  }
  long long prev = 0;
  for (long long i = int(0); i < int(m); i++) {
    long long x;
    cin >> x;
    prev ^= x;
    long long ans = minxor(root, prev);
    if (ans >= 300000) ans = 300000;
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
