#include<bits/stdc++.h>
#define FILE "read"
#define MAXN 300100
using namespace std;
int n,type;
inline int read(){
	int x=0,f=1;  char ch=getchar();
	while(ch>'9'||ch<'0')  {if(ch=='-')  f=-1;  ch=getchar();}
	while(ch>='0'&&ch<='9')  {x=x*10+ch-'0';  ch=getchar();}
	return x*f;
}
class Link_Cut_Tree{
	private:
		int tot,f[MAXN],col[MAXN],cnt[MAXN],tag[MAXN],st[MAXN],son[MAXN][2];
		inline bool isroot(int x){return son[f[x]][0]!=x&&son[f[x]][1]!=x;}
		inline bool get(int x){return son[f[x]][1]==x;}
		void pushdown(int x){
			if(tag[x]){
				if(son[x][0]) tag[son[x][0]]^=1,col[son[x][0]]^=1;
				if(son[x][1]) tag[son[x][1]]^=1,col[son[x][1]]^=1;
				tag[x]=0;
			}
		}
		inline void rotate(int x){
			int y=f[x],z=f[y],which=get(x);
			if(!isroot(y))  son[z][son[z][1]==y]=x;
			son[y][which]=son[x][which^1];  f[son[y][which]]=y;
			son[x][which^1]=y;  f[y]=x;  f[x]=z;
		}
		inline void splay(int x){
			int top=0;  st[++top]=x;
			for(int i=x;!isroot(i);i=f[i]) st[++top]=f[i];
			for(int i=top;i;--i) pushdown(st[i]);
			for(int y=f[x];!isroot(x);rotate(x),y=f[x])
				if(!isroot(y))  rotate(get(x)==get(y)?y:x);
		}
		inline int find(int x){
			while(son[x][0])  x=son[x][0];
			splay(x);  return x;
		}
		inline int access(int x,int y){
			while(x){
				splay(x);
				int z=son[x][1];
				if(z) son[x][1]=0,cnt[x]+=(col[find(z)]==0);
				if(col[y]==1) {if(col[x]==1) break;}
				else{
					if(cnt[x]>1) break;
					--cnt[x];
				}
				son[x][1]=y;  f[y]=x;
				y=find(x);  x=f[y];
			}
			tag[y]^=1;  col[y]^=1;
			if(col[y]){
				cnt[f[y]]--;
				return 0;
			}
			else{
				cnt[f[y]]++;
				return 1;
			}
		}
	public:
		void init(){tot=1; col[0]=1;}
		int insert(int y){
			int x=++tot;
			f[x]=y;  col[x]=1;
			return access(y,x);
		}
}Tree;
int main(){
	freopen(FILE".in","r",stdin);
	freopen(FILE".out","w",stdout);
	n=read();  type=read();  Tree.init();  int ans=1;
	for(int i=1;i<=n;++i){
		int x=read(); if(type&&i>1) x^=ans;
		ans+=Tree.insert(x+1);
		printf("%d\n",ans);
	}
	return 0;
}