#include<stdio.h>
#define Nmax 100005
FILE*f=fopen("arbint.in","r");
FILE*g=fopen("arbint.out","w");
int poz,Rez,a,b,X,q1,q2,M,N,i,t,A[4*Nmax];
void update(int nod,int st,int dr){
if ( st == dr ){
A[nod] = X;
return ;
}
int nodst = (nod << 1);
int noddr = nodst + 1;
int mj = st + ( dr - st ) / 2;
if ( poz <= mj ){
update(nodst,st,mj);
}
else{
update(noddr,mj+1,dr);
}
A[nod] = A[nodst] > A[noddr] ? A[nodst] : A[noddr];
}
void query(int nod,int st,int dr){
if ( a <= st && dr <= b ){
if ( Rez < A[nod] )
Rez = A[nod];
return ;
}
int nodst = nod << 1;
int noddr = nodst + 1;
int mj = st + ( dr - st ) / 2;
if ( a <= mj ){
query(nodst,st,mj);
}
if ( b > mj ){
query(noddr,mj + 1,dr);
}
}
int main () {
fscanf(f,"%d %d",&N,&M);
for ( i = 1 ; i <= N ; ++i ){
poz = i;
fscanf(f,"%d",&X);
update(1,1,N);
}
for ( i = 1 ; i <= M ; ++i ){
fscanf(f,"%d %d %d",&t,&q1,&q2);
if ( t ){
poz = q1; X = q2;
update(1,1,N);
}
else{
a = q1; b = q2;
Rez = -1;
query(1,1,N);
fprintf(g,"%d\n",Rez);
}
}
fclose(f);
fclose(g);
return 0;
}