#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
const int K = 2;
const int D = 19;
bool swapped[D];
struct Node {
  Node(int pos) : pos(pos), cnt(0), total(1 << (pos + 1)) {
    for (int i = 0; i < K; ++i) children[i] = nullptr;
  }
  int pos, cnt, total;
  Node* children[K];
};
void addNode(Node* node, int val, int pos) {
  if (pos < 0) {
    node->cnt = 1;
    return;
  }
  bool child = val & (1 << pos);
  if (node->children[child] == nullptr)
    node->children[child] = new Node(pos - 1);
  addNode(node->children[child], val, pos - 1);
  node->cnt = 0;
  for (int i = 0; i < K; ++i)
    if (node->children[i] != nullptr) node->cnt += node->children[i]->cnt;
}
int query(Node* node) {
  int pos = node->pos;
  if (pos < 0) return 0;
  int order[K];
  if (swapped[pos])
    order[0] = 1, order[1] = 0;
  else
    order[0] = 0, order[1] = 1;
  for (int i = 0; i < K; ++i) {
    int child = order[i];
    if (node->children[child] == nullptr)
      return ((child ^ swapped[pos]) << pos);
    if (node->children[child]->cnt < node->children[child]->total)
      return ((child ^ swapped[pos]) << pos) | query(node->children[child]);
  }
}
int main() {
  Node* root = new Node(D);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    addNode(root, x, D);
  }
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    for (int j = D; j >= 0; --j)
      if (x & (1 << j)) swapped[j] = !swapped[j];
    cout << query(root) << endl;
  };
  return 0;
}
