#include<cstdio>
#include<cstring>
#define Nmx 100001
#define MAX(a,b) (a>b) ? a : b
using namespace std;
int n,m;
int U[Nmx*6],A,B,val,pos,max;
void update(int nod,int st,int dr)
{
if(st==dr)
{
U[nod]=val;
return;
}
int mij=(st+dr)/2;
if(pos<=mij) update(nod*2,st,mij);
if(pos>mij) update(nod*2+1,mij+1,dr);
U[nod]=MAX(U[nod*2],U[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(B>mij) maxx(nod*2+1,mij+1,dr);
}
void citire()
{
int x,y,tip;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)
{
scanf("%d",&x);
val=x;pos=i;
update(1,1,n);
}
for(int i=1;i<=m;++i)
{
scanf("%d%d%d",&tip,&x,&y);
if(tip==0)
{
max=-1;
A=x;B=y;
maxx(1,1,n);
printf("%d\n",max);
}
else
{
pos=x;val=y;
update(1,1,n);
}
}
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
citire();
return 0;
}