#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-9;
const int N = 3e5 + 5;
const int M = 20;
struct Trip {
  int root, next[N * 20][2], sz[N * 20], pos;
  int newnode() {
    next[pos][0] = next[pos][1] = -1;
    sz[pos] = 0;
    return pos++;
  }
  void init() {
    pos = 0;
    root = newnode();
  }
  void insert(int x) {
    int cur = root;
    sz[cur]++;
    for (int i = M; i >= 0; i--) {
      int b = (x >> i) & 1;
      if (next[cur][b] == -1) next[cur][b] = newnode();
      cur = next[cur][b];
      sz[cur]++;
    }
    if (sz[cur] > 1) {
      cur = root;
      sz[cur]--;
      for (int i = M; i >= 0; i--) {
        int b = (x >> i) & 1;
        cur = next[cur][b];
        sz[cur]--;
      }
    }
  }
  int query(int x) {
    int cur = root;
    int ans = 0;
    for (int i = M; i >= 0; i--) {
      int b = (x >> i) & 1;
      if (next[cur][b] == -1) return ans;
      if (sz[next[cur][b]] < (1 << i))
        cur = next[cur][b];
      else {
        ans |= 1 << i;
        if (next[cur][b ^ 1] == -1) return ans;
        cur = next[cur][b ^ 1];
      }
    }
    return ans;
  }
};
int n, m, k;
Trip t;
int main() {
  scanf("%d%d", &n, &m);
  t.init();
  for (int i = 0; i < n; i++) {
    scanf("%d", &k);
    t.insert(k);
  }
  int p = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d", &k);
    p ^= k;
    printf("%d\n", t.query(p));
  }
  return 0;
}
