#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T maxs(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T mins(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
struct node {
  node* sons[2];
  long long cnt = 0;
};
node* create() {
  node* temp = new node();
  temp->sons[0] = NULL;
  temp->sons[1] = NULL;
  temp->cnt = 0;
  return temp;
}
template <typename node>
struct trie {
  node* root = new node();
  void insert(long long p) {
    node* temp = root;
    for (long long j = 20; j >= 0; j--) {
      temp->cnt++;
      long long k = (((1LL << j) & p) != 0);
      if (temp->sons[k] == NULL) {
        temp->sons[k] = create();
        temp = temp->sons[k];
      } else {
        temp = temp->sons[k];
      }
    }
    temp->cnt++;
  }
  void erase(long long p) {
    node* temp = root;
    for (long long j = 20; j >= 0; j--) {
      temp->cnt--;
      if (p & (1 << j))
        temp = temp->sons[1];
      else
        temp = temp->sons[0];
    }
    temp->cnt--;
  }
  long long query(long long val) {
    node* temp = root;
    long long ans = 0;
    for (long long j = 20; j >= 0; j--) {
      if ((1 << j) & val) {
        if (temp->sons[1])
          temp = temp->sons[1];
        else
          temp = temp->sons[0], ans += (1 << j);
      } else {
        if (temp->sons[0])
          temp = temp->sons[0];
        else
          temp = temp->sons[1], ans += (1 << j);
      }
    }
    return ans;
  }
};
trie<node> tr;
long long solve() {
  long long n, m;
  cin >> n >> m;
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    s.insert(t);
  }
  for (long long i = 0; i < (1 << 20); i++) {
    if (s.count(i) == 0) tr.insert(i);
  }
  long long last = 0;
  for (long long i = 0; i < m; i++) {
    long long first;
    cin >> first;
    last ^= first;
    cout << tr.query(last) << "\n";
  }
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
