#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,x,M,N,v[110000],t[440000],c,d,maxy;
void update(int nod, int st, int dr, int c, int d) {
if(st==dr) {
t[nod]=d;
return;
}
int mij = (st+dr)/2;
if(c<=mij) {
update(2*nod,st,mij,c,d);
} else {
update(2*nod+1,mij+1,dr,c,d);
}
t[nod] = max(t[2*nod],t[2*nod+1]);
}
int getmax(int nod, int st, int dr, int c, int d) {
int ret = 0;
if(c<=st && dr<=d) {
return t[nod];
}
int mij = (st+dr)/2;
if(d>mij) {
ret = max(ret,getmax(nod*2+1,1+mij,dr,c,d));
}
if(c<=mij) {
ret = max(ret,getmax(nod*2,st,mij,c,d));
}
return ret;
}
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);
update(1,1,N,i,x);
}
for(int i=1;i<=M;++i) {
scanf("%d%d%d",&x,&a,&b);
if(x==0) {
printf("%d\n",getmax(1,1,N,a,b));
} else {
update(1,1,N,a,b);
}
}
return 0;
}