#include <bits/stdc++.h>
using namespace std;
const long long N = 530000;
const long long mod = 1e9 + 7;
int f[20];
int sum[N];
int ans[N];
int a[20];
int main() {
  memset(ans, -1, sizeof(ans));
  memset(sum, 0, sizeof(sum));
  for (int i = 0; i <= 19; i++) f[i] = (1 << i) - 1;
  int n, m, x;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    sum[x] = 1;
  }
  for (int i = 1; i < N; i++) sum[i] += sum[i - 1];
  int num = 0;
  while (m--) {
    scanf("%d", &x);
    num ^= x;
    if (ans[num] != -1) {
      printf("%d\n", ans[num]);
      continue;
    }
    int w = 0, numm = num;
    int minn, maxx;
    while (1) {
      int flag = 0;
      for (int i = 0; i <= 19; i++) {
        minn = ((numm >> i) << i);
        maxx = minn + f[i];
        if (sum[maxx] - sum[minn] == f[i]) {
          if (minn == 0 && sum[0] == 1) {
            continue;
          } else if (minn > 0 && sum[minn] - sum[minn - 1] == 1)
            continue;
        }
        if (i == 0) {
          flag = 1;
          break;
        }
        numm ^= (1 << (i - 1));
        w += (1 << (i - 1));
        break;
      }
      if (flag) break;
    }
    printf("%d\n", w);
  }
}
