#include<bits/stdc++.h>
using namespace std;
struct node{
int val,sum,rfa,l,r;
bool lzy;
}a[100005];
int n,m;
bool heav(int now){
int t=a[now].rfa;
cout<<"heav :)"<<endl;
return now==a[t].l||now==a[t].r;
}
void pushup(int now){
a[now].sum=a[now].val^a[a[now].l].sum^a[a[now].r].sum;
cout<<"pushup :)"<<endl;
}
void revs(int now){
swap(a[now].l,a[now].r);
a[now].lzy^=1;
cout<<"revs :)"<<endl;
}
void pushdown(int now){
if(a[now].lzy){
if(a[now].l)revs(a[now].l);
if(a[now].r)revs(a[now].r);
a[now].lzy=0;
cout<<"pushdown :)"<<endl;
}
}
void spind(int now){
int t1=a[now].rfa,t2=a[t1].rfa;
if(a[t1].l==now){
if(heav(t1)){
if(a[t2].l==t1)a[t2].l=now;
else a[t2].r=now;
a[t1].l=a[now].r;a[now].r=t1;
if(a[t1].l){
a[a[t1].l].rfa=t1;
}
a[t1].rfa=now;
a[now].rfa=t2;
}
}
else{
if(heav(t1)){
if(a[t2].l==t1)a[t2].l=now;
else a[t2].r=now;
a[t1].r=a[now].l;a[now].l=t1;
if(a[t1].r){
a[a[t1].r].rfa=t1;
}
a[t1].rfa=now;
a[now].rfa=t2;
}
}
pushup(t1);
cout<<"spind :)"<<endl;
}
void splay(int now){
int ths=now;
vector<int>fc;
fc.push_back(ths);
while(heav(ths))fc.push_back(ths=a[ths].rfa);
for(int i=fc.size()-1;i>=0;i--){
pushdown(fc[i]);
}
while(heav(now)){
ths=a[now].rfa;
int t=a[ths].rfa;
if(heav(ths))spind((a[ths].l==now)^(a[t].l==ths)?now:ths);
spind(now);
}
pushup(now);
cout<<"splay :)"<<endl;
}
void access(int now){
for(int ths=0;now;now=a[ths=now].rfa){
splay(now);a[now].r=ths;pushup(now);
}
cout<<"access :)"<<endl;
}
void makeroot(int now){
access(now);splay(now);revs(now);
cout<<"makeroot :)"<<endl;
}
int findroot(int now){
access(now);splay(now);
while(a[now].l){
pushdown(now);
now=a[now].l;
}
splay(now);
cout<<"findroot :)"<<endl;
return now;
}
void split(int xx,int yy){
makeroot(xx);
access(yy);splay(yy);
cout<<"split :)"<<endl;
}
void conn(int xx,int yy){
makeroot(xx);
if(findroot(yy)!=xx)a[xx].rfa=yy;
cout<<"conn :)"<<endl;
}
void cut(int xx,int yy){
makeroot(xx);
if(findroot(yy)==xx&&a[yy].rfa==xx&&!a[yy].l){
a[yy].rfa=a[xx].r=0;
pushup(xx);
cout<<"cut :)"<<endl;
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].val;
}
while(m--){
int tp,xx,yy;
cin>>tp>>xx>>yy;
if(tp==0){
split(xx,yy);cout<<a[yy].sum<<endl;
}
if(tp==1)conn(xx,yy);
if(tp==2)cut(xx,yy);
if(tp==3){
splay(xx);a[xx].val=yy;
}
}
return 0;
}