#include <bits/stdc++.h>
using namespace std;
const int N = 19;
bool vis[1 << N];
struct Node {
  Node* arr[2];
  int weight;
  int num;
  Node() {
    arr[0] = NULL;
    arr[1] = NULL;
    weight = 0;
    num = 1;
  }
};
void buildTree(Node* root, int level, int n) {
  if (level == -1) return;
  root->num = n;
  root->arr[0] = new Node();
  buildTree(root->arr[0], level - 1, n * 2);
  root->arr[1] = new Node();
  buildTree(root->arr[1], level - 1, n * 2 + 1);
}
void add(int number, Node* root) {
  for (int i = N - 1; i >= 0; i--) {
    ++root->weight;
    if ((number >> i) & 1)
      root = root->arr[1];
    else
      root = root->arr[0];
  }
  ++root->weight;
}
int X;
int findMex(Node* root) {
  int ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    bool bit = (X >> i) & 1;
    if (root->arr[bit]->weight == (1 << i)) {
      ans += (1 << i);
      root = root->arr[!bit];
    } else {
      root = root->arr[bit];
    }
  }
  return ans;
}
int main() {
  Node* root = new Node();
  Node* node = new Node();
  node = root;
  buildTree(node, N, 1);
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    if (!vis[ai]) {
      add(ai, node);
      node = root;
    }
    vis[ai] = true;
  }
  while (m--) {
    int x;
    scanf("%d", &x);
    X ^= x;
    node = root;
    printf("%d\n", findMex(node));
  }
  return 0;
}
