#include <bits/stdc++.h>
#define dim 100005
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int v[4*dim],stq,drq,poz,val,r,a,b,n,m,i,tip;
void build(int nod,int st,int dr)
{
if(st==dr)
{
fin>>v[nod];
return;
}
int mid=(st+dr)/2;
build(nod*2,st,mid);
build(nod*2+1,mid+1,dr);
v[nod]=max(v[2*nod],v[2*nod+1]);
}
void query(int nod,int st,int dr)
{
if(stq<=st&&drq>=dr)
{
r=max(r,v[nod]);
return;
}
int mid=(st+dr)/2;
if(stq<=mid)
query(2*nod,st,mid);
if(drq>=mid+1)
query(2*nod+1,mid+1,dr);
}
void update(int nod,int st,int dr)
{
if(st==dr)
{
v[nod]=val;
return;
}
int mid=(st+dr)/2;
if(poz<=mid)
update(nod*2,st,mid);
else
update(nod*2+1,mid+1,dr);
v[nod]=max(v[2*nod],v[2*nod+1]);
}
int main()
{
fin>>n>>m;
build(1,1,n);
for(i=1; i<=m; i++)
{
fin>>tip>>a>>b;
if(tip==0)
{
stq=a;
drq=b;
r=0;
query(1,1,n);
fout<<r<<"\n";
}
else
{
poz=a;
val=b;
update(1,1,n);
}
}
}