#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define back return
#define ri register int
#define ull unsigned ll
#define node pair<ll,ll>
using namespace std;
using namespace __gnu_pbds;
tree<node,null_type,less<node>,rb_tree_tag,tree_order_statistics_node_update> t;
ll read()
{
ll x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
back x*f;
}
ll n,m,last,opt,x,res;
unordered_map<ll,ll> cnt;
int main()
{
n=read(),m=read();
for(ri i=1;i<=n;i++)
x=read(),t.insert(node(x,++cnt[x]));
for(ri i=1;i<=m;i++)
{
opt=read(),x=read();
x^=last;
if(opt==1)
t.insert(node(x,++cnt[x]));
if(opt==2)
t.erase(t.lower_bound(node(x,cnt[x]--)));
if(opt==3)
last=t.order_of_key(node(x,1))+1,res^=last;
if(opt==4)
last=t.find_by_order(x-1)->first,res^=last;
if(opt==5)
last=(--t.lower_bound(node(x,1)))->first,res^=last;
if(opt==6)
last=t.upper_bound(node(x+1,1))->first,res^=last;
}
cout<<res<<"\n";
back 0;
}