#include <cstdio>
using namespace std;
int v[100001],arbore[400001],maxx=0;
int Max (int a, int b)
{
return a>b ? a:b;
}
void build (int nod, int st, int dr)
{
if (st==dr)
{
arbore[nod]=v[st];
}
else
{
int mid=(st+dr)/2;
build (2*nod,st,mid);
build (2*nod+1,mid+1,dr);
arbore[nod]=Max(arbore[2*nod],arbore[2*nod+1]);
}
}
void update (int nod, int st, int dr, int poz, int val)
{
if (st==dr)
{
arbore[nod]=val;
}
else
{
int mid=(st+dr)/2;
if (poz<=mid)
{
update (2*nod,st,mid,poz,val);
}
else
{
update (2*nod+1,mid+1,dr,poz,val);
}
arbore[nod]=Max(arbore[2*nod],arbore[2*nod+1]);
}
}
void query (int nod, int st, int dr, int x, int y)
{
if (x<=st&&dr<=y)
{
maxx=Max(arbore[nod],maxx);
}
else
{
int mid=(st+dr)/2;
if (x<=mid)
{
query (2*nod,st,mid,x,y);
}
if (y>mid)
{
query (2*nod+1,mid+1,dr,x,y);
}
}
}
int main()
{
freopen ("arbint.in","r",stdin);
freopen ("arbint.out","w",stdout);
int M,N,i;
scanf ("%d %d",&N,&M);
for (i=1; i<=N; i++)
{
scanf ("%d",&v[i]);
}
build (1,1,N);
int t,m,n;
for (i=1;i<=M;i++)
{
scanf ("%d %d %d",&t,&m,&n);
if (t==0)
{
maxx=0;
query (1,1,N,m,n);
printf ("%d\n",maxx);
}
else
{
update (1,1,N,m,n);
}
}
return 0;
}