#include <bits/stdc++.h>
using namespace std;
struct node {
  int leaves;
  int val;
  struct node *left;
  struct node *right;
};
struct node *create(int n, int val) {
  if (n == 0) {
    return NULL;
  }
  if (val == -1) {
    struct node *temp = (struct node *)malloc(sizeof(struct node));
    temp->leaves = 0;
    temp->val = -1;
    temp->left = create(n, 0);
    temp->right = create(n, 1);
    return temp;
  } else if (val == 0) {
    struct node *temp = (struct node *)malloc(sizeof(struct node));
    temp->leaves = 0;
    temp->val = 0;
    temp->left = create(n - 1, 0);
    temp->right = create(n - 1, 1);
    return temp;
  } else {
    struct node *temp = (struct node *)malloc(sizeof(struct node));
    temp->leaves = 0;
    temp->val = 1;
    temp->left = create(n - 1, 0);
    temp->right = create(n - 1, 1);
    return temp;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long a, b, c, i, j, k, l, m, t, x, y, n, z;
  string s;
  cin >> n >> m;
  int a1[n];
  for (i = 0; i < n; i++) cin >> a1[i];
  struct node *root = create(19, -1);
  int done[400003];
  for (i = 0; i < 400003; i++) done[i] = 0;
  for (i = 0; i < n; i++) {
    int bits[19];
    z = a1[i];
    if (done[z] == 1) continue;
    done[z] = 1;
    for (j = 18; j >= 0; j--) {
      bits[j] = z % 2;
      z = z / 2;
    }
    struct node *temp = root;
    for (j = 0; j < 19; j++) {
      temp->leaves++;
      if (bits[j] == 1)
        temp = temp->right;
      else if (bits[j] == 0)
        temp = temp->left;
    }
    temp->leaves++;
  }
  long long old = 0;
  for (i = 0; i < m; i++) {
    cin >> a;
    long long ans = 0;
    x = 1 << 19;
    a = a ^ old;
    old = a;
    int bits[19];
    z = a;
    for (j = 18; j >= 0; j--) {
      bits[j] = z % 2;
      z = z / 2;
    }
    if (root->leaves == x) {
      cout << x << endl;
      return 0;
    }
    struct node *temp = root;
    for (j = 0; j < 19; j++) {
      if (bits[j] == 1) {
        if ((temp->right)->leaves < x / 2) {
          ans = ans + (x / 2);
          temp = temp->right;
        } else {
          temp = temp->left;
        }
      } else {
        if ((temp->left)->leaves < x / 2) {
          temp = temp->left;
        } else {
          ans = ans + (x / 2);
          temp = temp->right;
        }
      }
      x = x / 2;
    }
    cout << (ans ^ a) << endl;
  }
}
