#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n,a,b,o[100005],t,maxim,m,v[100005];
void build(int nod,int st,int dr)
{
if (st==dr) o[nod]=v[st];
else
{
int mij=(st+dr)/2;
build(2*nod,st,mij);
build(2*nod+1,mij+1,dr);
o[nod]=max(o[2*nod],o[2*nod+1]);
}
}
void query(int nod,int st,int dr,int a,int b)
{
if (a<=st&&b>=dr)
{
maxim=max(maxim,o[nod]);
}
else
{
int mij=(st+dr)/2;
if (a<=mij)
{
query(2*nod,st,mij,a,b);
}
if (b>mij)
{
query(2*nod+1,mij+1,dr,a,b);
}
}
}
void update(int nod,int st,int dr,int a,int b)
{
if (st==dr)
{
o[nod]=b;
}
else
{
int mij=(st+dr)/2;
if (a<=mij)
{
update(2*nod,st,mij,a,b);
}
if (a>mij)
{
update(2*nod+1,mij+1,dr,a,b);
}
o[nod]=max(o[nod*2],o[nod*2+1]);
}
}
int main()
{fin>>n>>m;
for (int i=1;i<=n;i++)
{
fin>>v[i];
}
build (1,1,n);
//fin>>m;
for (int i=1;i<=m;i++)
{
fin>>t>>a>>b;
if (t==0)
{
maxim=-999999999;
query(1,1,n,a,b);
fout<<maxim<<'\n';
}
else update(1,1,n,a,b);
}
return 0;
}