#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+2333;
int n,m;
int a[MAXN];
struct Persistable_Segment_Tree{
struct Node{
int val,L,R;
}t[MAXN*20];
int cnt,rt[MAXN*20];
void build_tree(int &root,int l,int r){
root=++cnt;
if (l==r) return (void)(t[root].val=a[l]);
int mid=l+r>>1;
build_tree(t[root].L,l,mid);
build_tree(t[root].R,mid+1,r);
}
void update(int &root,int las,int l,int r,int q,int opt){
root=++cnt;
t[root]=t[las];
if (l==r) return (void)(t[root].val=opt);
int mid=l+r>>1;
if (q<=mid) update(t[root].L,t[las].L,l,mid,q,opt);
else update(t[root].R,t[las].R,mid+1,r,q,opt);
}
int query(int root,int l,int r,int q){
if (l==r) return t[root].val;
int mid=l+r>>1;
if (q<=mid) return query(t[root].L,l,mid,q);
else return query(t[root].R,mid+1,r,q);
}
}T;
int read(){
int x=0,f=1; char ch=getchar();
while (!isdigit(ch)){ if (ch=='-') f=-1; ch=getchar(); }
while (isdigit(ch)) x=x*10+ch-'0',ch=getchar(); return x*f;
}
int main(){
n=read(),m=read();
for (int i=1;i<=n;i++) a[i]=read();
T.cnt=0,T.build_tree(T.rt[0],1,n);
int x,opt,y,z;
for (int i=1;i<=m;i++){
x=read(),opt=read();
if (opt==1){
y=read(),z=read();
T.update(T.rt[i],T.rt[x],1,n,y,z);
}
else {
y=read();
T.rt[i]=T.rt[x];
printf("%d\n",T.query(T.rt[x],1,n,y));
}
}
return 0;
}