#include<bits/stdc++.h>
using namespace std;
struct trees{
static int l,r,fun_x,fun_i,*fun_find_return;
struct node{
int v;node *l,*r;
node():v(0),l(nullptr),r(nullptr){};
node(node const&n){v=n.v,l=n.l,r=n.r;}
};
static void __init(int n_l,int n_r,node*now){
if(n_l+1==n_r){
cin>>now->v;
return ;
}
int mid=(n_l+n_r)>>1;
__init(n_l,mid,now->l=new node);
__init(mid,n_r,now->r=new node);
}
static void __find(int n_l,int n_r,node*now){
int mid=(n_l+n_r)>>1;
if(n_l+1==n_r) {
fun_find_return=&(now->v);
return;
}
if(fun_i<mid) return __find(n_l,mid,now->l);
return __find(mid,n_r,now->r);
}
static void __modify(int n_l,int n_r,node*now){
int mid=(n_l+n_r)>>1;
if(n_l+1==n_r) {
now->v=fun_x;
return;
}
if(fun_i<mid) {
__modify(n_l,mid,now->l=new node(*(now->l)));
return ;
}
__modify(mid,n_r,now->r=new node(*(now->r)));
}
static void __del__(node*now){
if(now->l)__del__(now->l);
if(now->r)__del__(now->r);
delete now;
}
struct tree{
node*root;
inline int&operator[](int i){
return fun_i=i,trees::__find(trees::l,trees::r,root),*fun_find_return;
}
inline void modify(int i,int x){
return fun_i=i,fun_x=x,trees::__modify(trees::l,trees::r,root=new node(*root));
}
inline void init(int l,int r){
trees::l=l,trees::r=r;
trees::__init(l,r,root=new node);
}
};
static tree t[],*cnt;
inline tree&operator[](int i){return t[i];}
inline tree&new_tree(tree&t){
return cnt->root=t.root,*(cnt++);
}
}t;
trees::tree trees::t[1200000],*trees::cnt=trees::t;
int trees::l=0,trees::r=0,trees::fun_x=0,trees::fun_i=0,*trees::fun_find_return=NULL;
int n,m,v,opt,l,val;
inline void read(int& rin){
int rout = 0,w = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-') w = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
rout = rout * 10 + ch - '0';
ch = getchar();
}
rin = rout * w;
}
void write(int x){
if(x < 0) putchar('-'),x=-x;
if(x > 9) write(x/10);
putchar(x%10 +'0');
}
int main(){
read(n),read(m);
(t.cnt++)->init(1,n+1);
while(m--){
read(v),read(opt),read(l);
if(opt==1){
read(val);
t.new_tree(t[v]).modify(l,val);
}else{
write(t.new_tree(t[v])[l]);putchar('\n');
}
}
return 0;
}