#include <bits/stdc++.h>
using namespace std;
int tire[600005 * 20][2], tot = 1;
int num[600005];
void insert(int a) {
  int rt = 0;
  for (int i = 19; i >= 0; i--) {
    int t = (a >> i) & 1;
    if (tire[rt][t] == 0) {
      tire[rt][t] = tot++;
    }
    rt = tire[rt][t];
  }
}
int query(int q) {
  int res = 0, rt = 0;
  for (int i = 19; i >= 0; i--) {
    int t = (q >> i) & 1;
    if (tire[rt][t] == 0) {
      res += (1 << i);
      rt = tire[rt][t ^ 1];
    } else
      rt = tire[rt][t];
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    num[x] = 1;
  }
  for (int i = 0; i <= 600001; i++) {
    if (!num[i]) insert(i);
  }
  int q = 0;
  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    q ^= x;
    cout << query(q) << '\n';
  }
  return 0;
}
