#include <iostream>
#include <cstdio>
#define maxim(a,b) ((a>b)?a:b)
using namespace std;
int arb[500000];
int n,op,m,nr,a,b,pozitie;
int nrmax;
void update(int nod,int st,int dr)
{
if (st==dr)
{
arb[nod]=nr;
return;
}
int mijloc=(st+dr)/2;
if (pozitie<=mijloc)
update(2*nod,st,mijloc);
else
update((2*nod+1),mijloc+1,dr);
arb[nod]=maxim(arb[2*nod],arb[2*nod+1]);
}
void aflare(int nod,int st,int dr)
{
if (st>=a && dr<=b)
{
nrmax=maxim(nrmax,arb[nod]);
return;
}
int mijloc=(st+dr)/2;
if (a<=mijloc)
aflare(2*nod,st,mijloc);
if (b>mijloc)
aflare(2*nod+1,mijloc+1,dr);
}
void citire()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)
{
scanf("%d",&nr);
pozitie=i;
update(1,1,n);
}
for (int i=1;i<=m;i++)
{
scanf("%d%d%d",&op,&a,&b);
if (op==0)
{
nrmax=-1;
aflare(1,1,n);
printf("%d\n",nrmax);
}
else
{
pozitie=a;
nr=b;
update(1,1,n);
}
}
}
int main()
{
citire();
return 0;
}