#include <bits/stdc++.h>
using namespace std;
const int twopower = 524288;
bool tree[525000], leaves[525000];
int main() {
  ios::sync_with_stdio(false);
  int n, m, a;
  int xorval = 0;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (leaves[a] == false) {
      leaves[a] = true;
      int iter = (twopower / 2) - 1 + (a / 2);
      int ctwopower = twopower / 2;
      if (leaves[a + (a % 2 == 0 ? 1 : -1)] == true) {
        tree[iter] = true;
        while (iter != 0) {
          if (tree[iter + (iter % 2 == 1 ? 1 : -1)] == true) {
            ctwopower /= 2;
            iter = (iter - 1) / 2;
            tree[iter] = true;
          } else {
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    int currval;
    cin >> currval;
    xorval = xorval ^ currval;
    int ctpower = twopower / 2;
    currval = 0;
    while (currval < 524288) {
      int pval = ((xorval & ctpower) == 0 ? 1 : 2);
      currval *= 2;
      if (ctpower != 1) {
        if (tree[currval + pval] == true) {
          currval += (3 - pval);
        } else {
          currval += pval;
        }
        ctpower /= 2;
      } else {
        if (leaves[(currval - 524287) + pval] == true) {
          currval += (3 - pval);
        } else {
          currval += pval;
        }
        break;
      }
    }
    cout << ((currval - 524287) ^ xorval) << endl;
  }
  return 0;
}
