#include<fstream>
#include<algorithm>
using namespace std;
int a[300015],n,q,x,tip,y,sol;
ifstream in("arbint.in"); ofstream out("arbint.out");
void update(int nod, int st, int dr, int poz, int val){
if(st==dr) a[nod]=val;
else{
int m=(st+dr)>>1;
if(poz<=m) update((nod<<1),st,m,poz,val);
else update((nod<<1)+1,m+1,dr,poz,val);
a[nod]=max(a[(nod<<1)],a[(nod<<1) +1]);
}
}
void querry(int nod, int st, int dr){
if(x<=st && dr<=y) sol=max(sol,a[nod]);
else{
int m=(st+dr)>>1;
if(x<=m) querry((nod<<1),st,m);
if(m<y ) querry((nod<<1)+1, m+1, dr);
}
}
int main(){
in>>n>>q;
for(int i=1;i<=n;++i){
in>>x;
update(1,1,n,i,x);
}
for(int i=1;i<=q;++i){
in>>tip>>x>>y;
if(tip) update(1,1,n,x,y);
else{
sol=-1;
querry(1,1,n);
out<<sol<<'\n';
}
}
return 0;
}