//21-11-19
#include<bits/stdc++.h>
#define scl(n) scanf("%d",&n)
#define pb push_back
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,q;
vector<int>v;
int main()
{
scl(n);
scl(q);
For(i,n)
{
int a;
scl(a);
v.pb(a);
}
For(i,q)
{
int typ;
scl(typ);
if(typ==1)
{
int k,x;
scl(k);
scl(x);
v.insert(v.begin()+k-1, x);
}
if(typ==2)
{
int k;
scl(k);
v.erase(v.begin()+k-1);
}
if(typ==3)
{
int k;
scl(k);
printf("%d\n",v[k-1]);
}
}
return 0;
}
Ly8yMS0xMS0xOQojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgoKI2RlZmluZSBzY2wobikgICBzY2FuZigiJWQiLCZuKQojZGVmaW5lIHBiICAgIHB1c2hfYmFjawojZGVmaW5lIEZvcihpLG4pICAgICBmb3IoaW50IGk9MDtpPG47aSsrKQp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4scTsKdmVjdG9yPGludD52OwppbnQgbWFpbigpCnsKICAgIHNjbChuKTsKICAgIHNjbChxKTsKICAgIEZvcihpLG4pCiAgICB7CiAgICAgICAgaW50IGE7CiAgICAgICAgc2NsKGEpOwogICAgICAgIHYucGIoYSk7CiAgICB9CiAgICBGb3IoaSxxKQogICAgewogICAgICAgIGludCB0eXA7CiAgICAgICAgc2NsKHR5cCk7CiAgICAgICAgaWYodHlwPT0xKQogICAgICAgIHsKICAgICAgICAgICAgaW50IGsseDsKICAgICAgICAgICAgc2NsKGspOwogICAgICAgICAgICBzY2woeCk7CiAgICAgICAgICAgIHYuaW5zZXJ0KHYuYmVnaW4oKStrLTEsIHgpOwogICAgICAgIH0KICAgICAgICBpZih0eXA9PTIpCiAgICAgICAgewogICAgICAgICAgICBpbnQgazsKICAgICAgICAgICAgc2NsKGspOwogICAgICAgICAgICB2LmVyYXNlKHYuYmVnaW4oKStrLTEpOwogICAgICAgIH0KICAgICAgICBpZih0eXA9PTMpCiAgICAgICAgewogICAgICAgICAgICBpbnQgazsKICAgICAgICAgICAgc2NsKGspOwogICAgICAgICAgICBwcmludGYoIiVkXG4iLHZbay0xXSk7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0KCg==