#include <bits/stdc++.h>
using namespace std;
mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
const int MAX = 29;
struct Node {
  Node *t, *first;
  int ct;
  Node() : ct(0), t(nullptr), first(nullptr){};
};
struct Trie {
  Node *head;
  Trie() { head = new Node(); }
  void add(int val) {
    Node *cur = head;
    for (int i = MAX; i >= 0; i--) {
      bool on = (1 << i) & val;
      if (on) {
        if (!cur->t) cur->t = new Node();
        cur = cur->t;
      } else {
        if (!cur->first) cur->first = new Node();
        cur = cur->first;
      }
    }
  }
  int process(Node *cur) {
    if (!cur) return 0;
    if (!cur->t and !cur->first) return cur->ct = 1;
    cur->ct += process(cur->t) + process(cur->first);
    return cur->ct;
  }
  void process() { process(head); }
  int query(Node *cur, int val, int l, int r) {
    int tot = r - l + 1;
    if ((tot / 2) & val) {
      if (!cur->t)
        return l;
      else if (cur->t->ct != tot / 2)
        return query(cur->t, val, l, (r + l) / 2);
      else if (!cur->first)
        return (r + l) / 2 + 1;
      else if (cur->first->ct != tot / 2)
        return query(cur->first, val, (r + l) / 2 + 1, r);
    } else {
      if (!cur->first)
        return l;
      else if (cur->first->ct != tot / 2)
        return query(cur->first, val, l, (r + l) / 2);
      else if (!cur->t)
        return (r + l) / 2 + 1;
      else if (cur->t->ct != tot / 2)
        return query(cur->t, val, (r + l) / 2 + 1, r);
    }
    return r + 1;
  }
  int query(int val) { return query(head, val, 0, (1 << (MAX + 1)) - 1); }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  Trie trie;
  for (auto &x : a) trie.add(x);
  trie.process();
  int q = 0;
  for (int i = 0, j; i < m; i++) {
    cin >> j;
    q ^= j;
    cout << trie.query(q) << endl;
  }
}
