#include <bits/stdc++.h>
using namespace std;
int trie[300000 * 23][3];
int alpha = 1;
void solve() {
  for (int i = 0; i < 300000 * 23; i++) trie[i][0] = trie[i][1] = -1;
  int n, m;
  cin >> n >> m;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    s.insert(temp);
  }
  for (auto temp : s) {
    int cur = 0;
    trie[cur][2]++;
    for (int i = 20; i >= 0; i--) {
      if ((temp & (1 << i)) == 0) {
        if (trie[cur][0] < 0) trie[cur][0] = alpha++;
      } else {
        if (trie[cur][1] < 0) trie[cur][1] = alpha++;
      }
      cur = trie[cur][(temp >> i) & 1];
      trie[cur][2]++;
    }
  }
  int curxor = 0;
  for (int _ = 0; _ < m; _++) {
    int quer;
    cin >> quer;
    curxor ^= quer;
    int cur = 0;
    int ans = 0;
    for (int i = 20; i >= 0; i--) {
      int pref = (curxor >> i) & 1;
      if (cur < 0)
        break;
      else {
        if (trie[trie[cur][pref]][2] != (1 << i)) {
          cur = trie[cur][pref];
          ans |= (0 << i);
        } else {
          cur = trie[cur][pref ^ 1];
          ans |= (1 << i);
        }
      }
    }
    cout << ans << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
