//#pragma GCC optimize(2)#include<bits/stdc++.h>usingnamespace std;typedeflonglong ll;#define SIS std::ios::sync_with_stdio(false)#define space putchar(' ')#define enter putchar('\n')#define lson root<<1#define rson root<<1|1typedef pair<int,int> PII;constint mod=1e9+7;constint N=1e7+5;intgcd(int a,int b){
return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){
return a*(b/gcd(a,b));}template<classT>voidread(T &x){
char c;bool op =0;while(c =getchar(), c <'0'|| c >'9')if(c =='-')
op =1;
x = c -'0';while(c =getchar(), c >='0'&& c <='9')
x = x *10+ c -'0';if(op)
x =-x;}template<classT>voidwrite(T x){
if(x <0)
x =-x,putchar('-');if(x >=10)write(x /10);putchar('0'+ x %10);}
ll qsm(int a,int b,int p){
ll res=1%p;while(b){
if(b&1)
res=res*a%p;
a=1ll*a*a%p;
b>>=1;}return res;}int trie[N][2],root, tot;int sum[N];int vis[N];voidInsert(int x){
if(vis[x])return;
vis[x]=1;
root =0;for(int i =30; i >=0; i--){
int id =x>>i&1;//转为2进制;if(!trie[root][id]){
trie[root][id]=++tot;}
root = trie[root][id];
sum[root]++;}//sum[root]=x;}intSearch(int x){
root =0;int res=0;for(int i =30; i>=0; i--){
int id =x>>i&1;if(sum[trie[root][id]]==(1<<i))///如果是满二叉树(全出现过{
root=trie[root][id^1];
res|=1<<i;}else
root=trie[root][id];}return res;}intmain(){
int n,m;scanf("%d%d",&n,&m);for(int i=1;i<=n;i++){
int x;scanf("%d",&x);Insert(x);}int tm=0;while(m--){
int x;scanf("%d",&x);
tm^=x;printf("%d\n",Search(tm));}return0;}