#include <bits/stdc++.h>
using namespace std;
struct trie {
  bool ending;
  trie* point[2];
};
trie* newnode() {
  trie* node = new trie;
  node->point[0] = node->point[1] = NULL;
  node->ending = false;
  return node;
}
trie* root = newnode();
int x = 0;
bool check[524288] = {false};
string convert(int x) {
  string s = "";
  for (int i = 0; i < 19; ++i) {
    s.push_back((x & 1) + '0');
    x >>= 1;
  }
  reverse(s.begin(), s.end());
  return s;
}
int convert(string s) {
  int ans = 0, base = 1;
  for (int i = s.size() - 1; i >= 0; --i) {
    ans += (s[i] - '0') * base;
    base <<= 1;
  }
  return ans;
}
void add(string s) {
  trie* cur = root;
  for (int i = 0; i < s.size(); ++i) {
    int id = s[i] - '0';
    if (cur->point[id] == NULL) cur->point[id] = newnode();
    cur = cur->point[id];
  }
  cur->ending = true;
}
void get(string s) {
  string ans = "";
  trie* cur = root;
  for (int i = 0; i < s.size(); ++i) {
    int id = s[i] - '0';
    if (cur->point[0] != NULL && cur->point[1] != NULL) {
      ans.push_back('0');
      cur = cur->point[id];
    } else if (cur->point[0] != NULL) {
      ans.push_back((id ^ 0) + '0');
      cur = cur->point[0];
    } else {
      ans.push_back((id ^ 1) + '0');
      cur = cur->point[1];
    }
  }
  cout << convert(ans) << "\n";
}
void inp() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    int num;
    cin >> num;
    check[num] = true;
  }
  for (int i = 0; i < 524288; ++i) {
    if (!check[i]) add(convert(i));
  }
  for (int i = 1; i <= q; ++i) {
    int num;
    cin >> num;
    x ^= num;
    get(convert(x));
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  inp();
  return 0;
}
