#include <fstream>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int N,M;
int Arb[100002],Value[100002];
void Read()
{
int i;
f>>N>>M;
for(i=1;i<=N;i++)
f>>Value[i];
}
void Build(int K,int L,int R)
{
int Mid=(L+R)/2;
if(L==R)
{
Arb[K]=Value[L];
return;
}
Build(2*K,L,Mid);
Build(2*K+1,Mid+1,R);
Arb[K]=max(Arb[2*K+1],Arb[2*K]);
}
void Update(int K,int L,int R,int Poz,int Val)
{
int Mid=(L+R)/2;
if(L==R)
{
Arb[K]=Val;
return;
}
if(Mid<Poz)
Update(2*K+1,Mid+1,R,Poz,Val);
else
Update(2*K,L,Mid,Poz,Val);
Arb[K]=max(Arb[2*K],Arb[2*K+1]);
}
int Qwery(int K,int L,int R,int QL,int QR)
{
int Mid=(L+R)/2;
if(QL<=L && R<=QR)
return Arb[K];
int QMax=0;
if(QL<=Mid)
QMax=max(QMax,Qwery(2*K,L,Mid,QL,QR));
if(QR>Mid)
QMax=max(QMax,Qwery(2*K+1,Mid+1,R,QL,QR));
return QMax;
}
void Browse()
{
int i;
for(i=1;i<=M;i++)
{
int type,a,b;
f>>type>>a>>b;
if(type==1)
{
Value[a]=b;
Update(1,1,N,a,b);
}
if(type==0)
g<<Qwery(1,1,N,a,b)<<"\n";
}
}
int main()
{
Read();
Build(1,1,N);
Browse();
return 0;
}