#include<stdio.h>
#define Nmx 100001
int n,m;
int a[Nmx],U[2*Nmx],A,B,max;
int MAX(int a,int b)
{
if(U[a]>U[b]) return U[a];
else return U[b];
}
void update(int nod,int st,int dr)
{
if(st==dr)
{
U[nod]=a[st];
return ;
}
int mij=(st+dr)/2;
update(2*nod,st,mij);
update(2*nod+1,mij+1,dr);
U[nod]=MAX(nod*2,nod*2+1);
}
void maxx(int nod,int st,int dr)
{
if(st>=A&&dr<=B)
{
if(U[nod]>max) max=U[nod];
return ;
}
int mij=(st+dr)/2;
if(A<=mij) maxx(nod*2,st,mij);
if(mij<B) maxx(nod*2+1,mij+1,dr);
}
void citire()
{
int c,x,y;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)
scanf("%d",&a[i]);
update(1,1,n);
for(int i=1;i<=m;++i)
{
scanf("%d%d%d",&c,&x,&y);
max=-1;
if(c==0)
{
A=x;B=y;
maxx(1,1,n);
printf("%d\n",max);
}
else {
a[x]=y;
update(1,1,n);
}
}
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
citire();
return 0;
}