#include<bits/stdc++.h>
#define N 300005
using namespace std;
int n,m,v[N],top,ch[N][2],fa[N],q[N],xr[N],rev[N];
inline void pushup(int x)
{
xr[x]=xr[ch[x][0]]^xr[ch[x][1]]^v[x];
}
inline void pushdown(int x)
{
if(rev[x])
{
rev[ch[x][0]]^=1;
rev[ch[x][1]]^=1;
rev[x]=0;
swap(ch[x][0],ch[x][1]);
}
}
inline bool isroot(int x)
{
return ch[fa[x]][0]!=x&&ch[fa[x]][1]!=x;
}
inline void rotate(int x)
{
int y=fa[x],z=fa[y],l,r;
if(ch[y][0]==x) l=0;
else l=1;
r=l^1;
if(!isroot(y))
{
if(ch[z][0]==y) ch[z][0]=x;
else ch[z][1]=x;
}
fa[x]=z;
fa[y]=x;
fa[ch[x][r]]=y;
ch[y][l]=ch[x][r];
ch[x][r]=y;
pushup(y);
pushup(x);
}
inline void splay(int x)
{
top=1;
q[top]=x;
for(int i=x;!isroot(i);i=fa[i]) q[++top]=fa[i];
for(int i=top;i;i--) pushdown(q[i]);
while(!isroot(x))
{
int y=fa[x],z=fa[y];
if(!isroot(y))
{
if((ch[y][0]==x)^(ch[z][0]==y)) rotate(x);
else rotate(y);
}
rotate(x);
}
}
inline void access(int x)
{
for(int i=0;x;i=x,x=fa[x])
{
splay(x);
ch[x][1]=i;
pushup(x);
}
}
inline void makeroot(int x)
{
access(x);
splay(x);
rev[x]^=1;
pushup(x);
}
inline int find(int x)
{
access(x);
splay(x);
while(ch[x][0]) pushdown(x),x=ch[x][0];
return x;
}
inline void split(int x,int y)
{
makeroot(x);
access(y);
splay(y);
}
inline void cut(int x,int y)
{
split(x,y);
if(ch[y][0]==x)
{
ch[y][0]=0;
fa[x]=0;
}
pushup(x);
}
inline void link(int x,int y)
{
makeroot(x);
fa[x]=y;
pushup(y);
}
int main()
{
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%d",&v[i]);
}
while(m--)
{
int order,x,y;
scanf("%d %d %d",&order,&x,&y);
switch(order)
{
case 0: {
split(x,y);
printf("%d\n",xr[y]);
break;
}
case 1: {
if(find(x)!=find(y)) link(x,y);
break;
}
case 2: {
split(x,y);
if(find(x)==find(y)) link(x,y);
break;
}
case 3: {
access(x);
splay(x);
v[x]=y;
pushup(x);
break;
}
}
}
return 0;
}