#include <iostream>
#include <fstream>
using namespace std;
int v[400001];
int a[100001];
void build(int poz, int st, int dr){
if(st==dr){
v[poz]=a[st];
// cout<<poz<<' '<<v[poz]<<'\n';
return;
}
int mij=(dr+st)/2;
build(poz*2,st,mij);
build(poz*2+1,mij+1,dr);
v[poz]=max(v[2*poz],v[2*poz+1]);
}
void update(int poz, int st, int dr){
if(st==dr){
v[poz]=a[st];
// cout<<poz<<' '<<v[poz]<<'\n';
return;
}
int mij=(dr+st)/2;
update(poz*2,st,mij);
update(poz*2+1,mij+1,dr);
v[poz]=max(v[2*poz],v[2*poz+1]);
// cout<<poz<<' '<<v[poz]<<'\n';
}
int rez(int poz, int x, int y, int st, int dr){
if(st>=x&&dr<=y){
return v[poz];
}
int mij=(st+dr)/2;
if(dr<x||st>y){
return -1;
}
return max(rez(2*poz,x,y,st,mij),rez(2*poz+1,x,y,mij+1,dr));
}
int main()
{
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m, t, x, y;
fin>>n>>m;
for(int i=1;i<=n;i++){
fin>>a[i];
}
build(1,1,n);
for(int i=0;i<m;i++){
fin>>t>>x>>y;
if(t==0){
fout<<rez(1,x,y,1,n)<<'\n';
}
else{
//cout<<a[y]<<'\n';
a[x]=y;
update(1,1,n);
}
}
return 0;
}