#include <bits/stdc++.h>
using namespace std;
struct node {
  struct node* left;
  struct node* right;
  int vl;
  node() {
    vl = 0;
    left = NULL;
    right = NULL;
  }
};
int a[300005];
int ans = 0;
void query(node* n, int v, int i, int j) {
  if (n == NULL || j == 0) return;
  int no = (1 << (j - 1));
  node* l2 = n->left;
  node* r2 = n->right;
  int l1 = 0, r1 = 0;
  if (l2 != NULL) l1 = l2->vl;
  if (r2 != NULL) r1 = r2->vl;
  j--;
  if ((v & (1 << j)) == 0) {
    if (l1 == no) {
      ans += (1 << (j));
      query(n->right, v, i / 2, j);
      return;
    }
    query(n->left, v, i / 2, j);
    return;
  }
  if (r1 == no) {
    ans += (1 << (j));
    query(n->left, v, i / 2, j);
    return;
  }
  query(n->right, v, i / 2, j);
  return;
}
void insert(node* n, int val, int i, int j) {
  if (j == 0) return;
  j--;
  if ((val & (1 << j)) == 0) {
    if (n->left == NULL) {
      node* cur = new node();
      n->left = cur;
    }
    insert(n->left, val, i / 2, j);
    return;
  }
  if (n->right == NULL) {
    node* cur = new node();
    n->right = cur;
  }
  insert(n->right, val, i / 2, j);
  return;
}
int dfs(node* n) {
  if (n->left == NULL && n->right == NULL) {
    n->vl = 1;
    return 1;
  }
  int w = 0;
  int u = 0;
  if (n->left != NULL) {
    w += dfs(n->left);
    u++;
  }
  if (n->right != NULL) {
    w += dfs(n->right);
    u++;
  }
  n->vl = w;
  return w;
}
int main() {
  int n, m;
  cin >> n >> m;
  node* h = new node();
  node* w1 = h;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    h = w1;
    insert(h, a[i], (1 << 20) - 1, 19);
  }
  int x = 0;
  h = w1;
  dfs(h);
  for (int i = 1; i <= m; i++) {
    int x1;
    cin >> x1;
    x = x ^ x1;
    ans = 0;
    h = w1;
    query(h, x, (1 << 20) - 1, 19);
    cout << ans << '\n';
  }
}
