#include<stdio.h>
FILE*f=fopen("arbint.in","r");
FILE*g=fopen("arbint.out","w");
int i,a,b,n,m,x,k,x1,x2,v[400001],max;
int maxx(int a,int b){
if(a>b)
return a;
else
return b;
}
void update(int nod,int st,int dr){
if(st==dr){
v[nod]=x;
return ;
}
int nodst=(nod<<1);
int noddr=nodst+1;
int m=(st+dr)/2;
if(i<=m)
update(nodst,st,m);
else
update(noddr,m+1,dr);
v[nod]=maxx(v[nodst],v[noddr]);
}
void query(int nod,int st,int dr){
if(a<=st&&dr<=b){
if(max<v[nod])
max=v[nod];
return ;
}
int nodst=(nod<<1);
int noddr=nodst+1;
int m=(dr+st)/2;
if(a<=m)
query(nodst,st,m);
if(b>m)
query(noddr,m+1,dr);
}
int main() {
fscanf(f,"%d%d",&n,&m);
for(i=1;i<=n;++i){
fscanf(f,"%d",&x);
update(1,1,n);
}
for(int j=1;j<=m;++j){
fscanf(f,"%d%d%d",&k,&x1,&x2);
if(k){
i=x1;
x=x2;
update(1,1,n);
}else{
a=x1;
b=x2;
max=0;
query(1,1,n);
fprintf(g,"%d\n",max);
}
}
fclose(g);
fclose(f);
return 0;
}