#include <cstdlib>
#include <stdio.h>
using namespace std;
int MaxInt[400100],a,b,poz,val,x,maxim,start,stop,n,m;
inline int max(int a, int b){
if (a>b) return a;
return b;
}
void update(int nod, int st, int dr){
if (st==dr){
MaxInt[nod]=val;
return;
}
int mij=(st+dr)/2;
if (poz>mij)
update(2*nod+1,mij+1,dr);
else
update(2*nod,st,mij);
MaxInt[nod]=max(MaxInt[2*nod],MaxInt[2*nod+1]);
}
void interogare(int nod, int st, int dr){
if (start<=st && dr<=stop){
if (maxim<MaxInt[nod]) maxim=MaxInt[nod];
return;
}
int mij=(st+dr)/2;
if (start<=mij) interogare(2*nod,st,mij);
if ( mij<stop ) interogare(2*nod+1,mij+1,dr);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d %d",&n,&m);
for (int i=1;i<=n;i++){
scanf("%d",&x);
poz=i;
val=x;
update(1,1,n);
}
for (int i=1;i<=m;i++){
scanf("%d %d %d", &x, &a, &b);
if (x){
poz=a;
val=b;
update(1,1,n);
}
else {
maxim=-1;
start=a;
stop=b;
interogare(1,1,n);
printf("%d\n",maxim);
}
}
return 0;
}