#include <bits/stdc++.h>
using namespace std;
const double sn = 1e-6;
const int siz = 300005;
int n, m;
int arr[siz], p2[20];
bool ex[300005], bin[300005][19];
int ln = 2, sz = 19;
struct node {
  node* ch[2];
};
node* fn = new node();
bool pass[19];
void add(node* nod, int k) {
  if (k == -1) {
    return;
  }
  if (nod->ch[pass[k]] == NULL) {
    nod->ch[pass[k]] = new node();
  }
  add(nod->ch[pass[k]], k - 1);
}
int solve(node* nod, int x, int k, int res) {
  if (k == -1) return res;
  if (nod->ch[bin[x][k]] != NULL)
    return solve(nod->ch[bin[x][k]], x, k - 1, res + bin[x][k] * (1 << k));
  return solve(nod->ch[!bin[x][k]], x, k - 1, res + (!bin[x][k]) * (1 << k));
}
void binary(int i) {
  int in = i;
  bool le = (i <= 300000);
  for (int j = 18; j >= 0; j--) {
    if (p2[j] <= i) {
      if (le) bin[in][j] = true;
      pass[j] = true;
      i -= p2[j];
    } else {
      pass[j] = false;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    ex[arr[i]] = true;
  }
  int t = 1;
  for (int i = 0; i < 20; i++) {
    p2[i] = t;
    t *= 2;
  }
  for (int i = 0; i <= 524287; i++) {
    binary(i);
    if (i > 300000 || !ex[i]) {
      add(fn, sz - 1);
    }
  }
  int in = 0;
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    x ^= in;
    printf("%d\n", solve(fn, x, sz - 1, 0) ^ x);
    in = x;
  }
  return 0;
}
