#include <bits/stdc++.h>
using namespace std;
int eix[524290];
int n, q;
int tr[6000007][2];
struct Run {
  int tmp[23], cnt;
  int Creat() {
    tr[cnt][0] = tr[cnt][1] = -1;
    return cnt++;
  }
  int Find() {
    int now = 0, w = 0;
    for (int i = 21; i >= 0; i--) {
      if (tr[now][tmp[i]] != -1)
        now = tr[now][tmp[i]];
      else
        now = tr[now][1 - tmp[i]], w |= (1 << i);
    }
    return w;
  }
  void ok_tmp(int x) {
    memset(tmp, 0, sizeof(tmp));
    int num = 0;
    while (x) {
      tmp[num++] = x & 1;
      x >>= 1;
    }
  }
  void ins(int x) {
    ok_tmp(x);
    int now = 0, m;
    for (int i = 21; i >= 0; i--) {
      m = tmp[i];
      if (tr[now][m] == -1) tr[now][m] = Creat();
      now = tr[now][m];
    }
  }
  void solve() {
    int x;
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      eix[x] = 1;
    }
    Creat();
    for (int i = 0; i <= 524288; i++)
      if (!eix[i]) ins(i);
    int now = 0;
    Creat();
    for (int i = 0; i < q; i++) {
      scanf("%d", &x);
      now ^= x;
      ok_tmp(now);
      printf("%d\n", Find());
    }
  }
};
int main() {
  Run cc = Run();
  cc.solve();
  return 0;
}
