#include <cstdio>
#include <algorithm>
using namespace std;
int arb[1<<19];
int n,m,i,op,a,b,poz,x;
inline void actualizare(int nod, int st, int dr)
{
int m;
if (poz<=st&&poz>=dr)
{
arb[nod]=x;
return;
}
m=(st+dr)/2;
if (poz<=m) actualizare(2*nod,st,m);
else actualizare(2*nod+1,m+1,dr);
if (arb[nod*2]<arb[2*nod+1]) arb[nod]=arb[2*nod+1];
else arb[nod]=arb[2*nod];
}
inline int interogare(int nod, int st, int dr)
{
int m,x1,x2;
x1=x2=0;
if (a<=st&&b>=dr)
return arb[nod];
m=(st+dr)/2;
if (a<=m) x1=interogare(nod*2,st,m);
if (b>m) x2=interogare(nod*2+1,m+1,dr);
if (x2>x1) x1=x2;
return x1;
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d %d",&n,&m);
for (i=1;i<=n;i++)
{
scanf("%d",&x);
poz=i;
actualizare(1,1,n);
}
for (i=1;i<=m;i++)
{
scanf("%d %d %d",&op,&a,&b);
if (op==0)
printf("%d\n",interogare(1,1,n));
else
{
poz=a;
x=b;
actualizare(1,1,n);
}
}
return 0;
}