#include <cstdio>
#include <cctype>
#define BUF_SIZE 1<<17
#define MAXN 100000
#define MAXP 265000
int v[MAXN+1], aint[MAXP];
int n, left, right, poz, ans;
int pos=BUF_SIZE, pos2;
char buf[BUF_SIZE], buf2[BUF_SIZE];
FILE *fin, *fout;
inline char nextch(){
if(pos==BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0;
return buf[pos++];
}
inline int read(){
int x=0;
char ch=nextch();
while(!isdigit(ch)) ch=nextch();
while(isdigit(ch)){
x=10*x+ch-'0';
ch=nextch();
}
return x;
}
inline void putch(char ch){
buf2[pos2++]=ch;
if(pos2==BUF_SIZE) fwrite(buf2, BUF_SIZE, 1, fout), pos2=0;
}
inline void baga(int x){
char s[10];
int k=0;
do{
s[k++]=x%10+'0';
x/=10;
}while(x);
while(k>0){
k--;
putch(s[k]);
}
}
inline int max2(int a, int b){
if(a>b) return a;
else return b;
}
void dfs(int p, int st, int dr){
if(st==dr) aint[p]=v[st];
else{
int m=(st+dr)/2;
dfs(2*p, st, m);
dfs(2*p+1, m+1, dr);
aint[p]=max2(aint[2*p], aint[2*p+1]);
}
}
inline void update(){
int p=1, st=1, dr=n, m;
while(st<dr){
m=(st+dr)/2;
if(poz<=m) dr=m, p*=2;
else st=m+1, p=2*p+1;
}
aint[p]=v[st];
p/=2;
while(p){
aint[p]=max2(aint[2*p], aint[2*p+1]);
p/=2;
}
}
inline void query(){
if(left==right) ans=v[left];
else{
int p=1, st=1, dr=n, m=(n+1)/2, cp, cst, cdr;
while((right<=m)||(m+1<=left)){
if(right<=m) dr=m, p*=2;
else st=m+1, p=2*p+1;
m=(st+dr)/2;
}
cp=p;
cst=st;
cdr=dr;
dr=m;
p*=2;
while(st<left){
m=(st+dr)/2;
if(m+1<=left) st=m+1, p=2*p+1;
else{
ans=max2(ans, aint[2*p+1]);
dr=m;
p*=2;
}
}
ans=max2(ans, aint[p]);
st=cst;
dr=cdr;
p=cp;
m=(st+dr)/2;
st=m+1;
p=2*p+1;
while(right<dr){
m=(st+dr)/2;
if(right<=m) dr=m, p*=2;
else{
ans=max2(ans, aint[2*p]);
st=m+1;
p=2*p+1;
}
}
ans=max2(ans, aint[p]);
}
}
int main(){
int m, a, b, c;
fin=fopen("arbint.in", "r");
fout=fopen("arbint.out", "w");
n=read();
m=read();
for(int i=1; i<=n; i++)
v[i]=read();
dfs(1, 1, n);
for(int i=1; i<=m; i++){
a=read();
b=read();
c=read();
if(a==0){
left=b;
right=c;
ans=0;
query();
baga(ans);
putch('\n');
}else{
poz=b;
v[poz]=c;
update();
}
}
if(pos2>0) fwrite(buf2, pos2, 1, fout);
fclose(fin);
fclose(fout);
return 0;
}