#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int x,y,n,m,sol,operatie,a[200005];
void update(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
a[nod]=val;
else
{
int m=(st+dr)/2;
if(poz<=m)
update(nod*2,st,m,poz,val);
else
update(nod*2+1,m+1,dr,poz,val);
a[nod]=max(a[nod*2],a[nod*2+1]);
}
}
void query(int nod, int st, int dr)
{
if(x<=st && dr<=y)
sol=max(sol,a[nod]);
else
{
int m=(st+dr)/2;
if(x<=m)
query(nod*2,st,m);
if(m<y)
query(nod*2+1,m+1,dr);
}
}
int main()
{
f>>n>>m;
for(int i=1;i<=n;++i)
{
f>>x;
update(1,1,n,i,x);
}
for(int i=1;i<=m;++i)
{
f>>operatie>>x>>y;
if(operatie==0)
{
query(1,1,n);
g<<sol<<'\n';
}
else
{
update(1,1,n,x,y);
}
}
return 0;
}