#include <bits/stdc++.h>
using namespace std;
const int N = 531000;
int sw = 0;
struct Trie {
  int cnt[N * 20];
  void Insert(int node, int pos, int num) {
    if (pos < 0) {
      cnt[node] = 1;
      return;
    }
    Insert(node << 1 | ((num >> pos) & 1), pos - 1, num);
    cnt[node] = cnt[node << 1] + cnt[node << 1 | 1];
  }
  int Query(int node, int pos, int num) {
    if (pos < 0) return num;
    int cur = (sw >> pos) & 1;
    cur |= node << 1;
    if (cnt[cur] < (1 << pos)) return Query(cur, pos - 1, num);
    return Query(cur ^ 1, pos - 1, num + (1 << pos));
  }
} trie;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (register int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    trie.Insert(1, 19, x);
  }
  while (m--) {
    int x;
    scanf("%d", &x);
    sw ^= x;
    printf("%d\n", trie.Query(1, 19, 0));
  }
  return 0;
}
