#include <stdio.h>
FILE *f=fopen("arbint.in","r"),*g=fopen("arbint.out","w");
int arb[200001],mar[200001],i,j,n,val,x,pos,m,a,b,st,dr,max;
int update(int nod,int x,int y)
{
if (x==y)
{
mar[nod]=val;
return 0;
}
int m=(x+y)/2;
if (pos<=m) update(2*nod,x,m);
else update(2*nod+1,m+1,y);
if (mar[2*nod]>mar[2*nod+1]) mar[nod]=mar[2*nod];
else mar[nod]=mar[2*nod+1];
return 0;
}
int query(int nod,int x,int y)
{
if (st<=x && dr>=y)
{
if (max<mar[nod]) max=mar[nod];
return 0;
}
int m=(x+y)/2;
if (st<=m) query(2*nod,x,m);
if (dr>m) query(2*nod+1,m+1,y);
return 0;
}
int main(void)
{
fscanf(f,"%d%d",&n,&m);
for (i=1;i<=n;i++)
{
fscanf(f,"%d",&val);
pos=i;
update(1,1,n);
}
for (i=1;i<=m;i++)
{
fscanf(f,"%d%d%d",&x,&a,&b);
if (x==1)
{
pos=a;
val=b;
update(1,1,n);
}
else
{
st=a;
dr=b;
max=-1;
query(1,1,n);
fprintf(g,"%d\n",max);
}
}
fclose(g);
return 0;
}