#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int M = 6e5 + 5;
int t, n, m, q, t2;
string num;
int arr[N];
bool sw[19];
class Trie {
 public:
  Trie *child[2];
};
Trie rev_trie;
void recins(int idx, Trie *curr) {
  if (idx > 18) return;
  if (num[idx] == '0') {
    if ((*curr).child[0] == 0) (*curr).child[0] = new Trie();
    curr = (*curr).child[0];
  } else {
    if ((*curr).child[1] == 0) (*curr).child[1] = new Trie();
    curr = (*curr).child[1];
  }
  recins(idx + 1, curr);
}
bool recdel(int idx, Trie *curr) {
  if (idx > 18) return true;
  int next;
  if (num[idx] == '0') {
    if ((*curr).child[0] == 0) return false;
    next = 0;
  } else {
    if ((*curr).child[1] == 0) return false;
    next = 1;
  }
  if (recdel(idx + 1, (*curr).child[next])) {
    if ((curr->child[next]->child[0] == curr->child[next]->child[1])) {
      curr->child[next] = 0;
    }
    return true;
  } else
    return false;
}
bool recfind(int idx, Trie *curr) {
  if (idx > 18) return true;
  if (num[idx] == '0') {
    if ((*curr).child[0] == 0) return false;
    curr = (*curr).child[0];
  } else {
    if ((*curr).child[1] == 0) return false;
    curr = (*curr).child[1];
  }
  return recfind(idx + 1, curr);
}
int mex(int idx, Trie *curr) {
  if (idx > 18) return 0;
  int ret = 0;
  if ((*curr).child[0 ^ sw[idx]] == 0) {
    curr = (*curr).child[1 ^ sw[idx]];
    ret = (1 << (18 - idx));
  } else {
    curr = (*curr).child[0 ^ sw[idx]];
  }
  return ret + mex(idx + 1, curr);
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", arr + i);
  }
  sort(arr, arr + n);
  int ddd = 0;
  arr[n] = -10;
  for (int i = 0; i < (1 << 19); ++i) {
    if ((i == arr[ddd]))
      while (i == arr[ddd]) ++ddd;
    else {
      bitset<19> b(i);
      num = b.to_string();
      recins(0, &rev_trie);
    }
  }
  for (int x = 0; x < q; ++x) {
    scanf("%d", &t);
    bitset<19> b(t);
    num = b.to_string();
    for (int i = 0; i < 19; ++i) {
      if (num[i] == '1') sw[i] = !sw[i];
    }
    printf("%d\n", mex(0, &rev_trie));
  }
}
