#include <bits/stdc++.h>
using namespace std;
const string file="arbint";
ifstream f(file+".in");
ofstream g(file+".out");
//#define f cin
//#define g cout
#define DD 100066
int t[4*DD],Max;
int n,m,cer,x,y;
void update(int nod, int val, int poz, int st, int dr){
if(st==dr) t[nod]=val;
else{
int mij=(st+dr)/2;
if(poz<=mij) update(nod*2,val,poz,st,mij);
else update(nod*2+1,val,poz,mij+1,dr);
t[nod]=max(t[2*nod],t[2*nod+1]);
}
}
void querry(int nod, int st, int dr, int x, int y){
if(x<=st && dr<=y){
if(t[nod]>Max) Max=t[nod];
return;
}
int mij=(st+dr)/2;
if(x<=mij) querry(nod*2,st,mij,x,y);
if(y>mij) querry(nod*2+1,mij+1,dr,x,y);
}
int main(){
f>>n>>m;
for(int i=1; i<=n; ++i){
f>>x;
int poz=i,val=x;
update(1,val,poz,1,n);
}
for(int i=1; i<=m; ++i){
f>>cer>>x>>y;
if(cer==0){
Max=INT_MIN;
querry(1,1,n,x,y);
g<<Max<<'\n';
}
else update(1,y,x,1,n);
}
return 0;
}