#include <cstdio>
#include <algorithm>
using namespace std;
int a[400001], Max;
void update (int val, int poz, int nod, int p, int r)
{
int m=(p+r)/2;
if (p==poz && r==poz)
{
a[nod]=val;
while (nod>0)
{
nod/=2;
a[nod]=max(a[nod*2],a[nod*2+1]);
}
return;
}
if (m>=poz)
{
update(val,poz,nod*2,p,m);
}
else
{
update(val,poz,nod*2+1,m+1,r);
}
}
void query (int x, int y, int nod, int p, int r)
{
int m=(p+r)/2;
if (p>=x && r<=y)
{
Max=max(Max,a[nod]);
return;
}
if (p<x && m+1<=y)
{
query(x,y,nod*2+1,m+1,r);
}
if (r>=y && m>=x)
{
query(x,y,nod*2,p,m);
}
}
int main()
{
int n, m, i, p, x, y;
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
for (i=1; i<=n; i++)
{
scanf("%d",&x);
update(x,i,1,1,n);
}
for (i=1; i<=m; i++)
{
scanf("%d%d%d",&p,&x,&y);
if (p==0)
{
Max=0;
query(x,y,1,1,n);
printf("%d\n",Max);
}
else
{
update(y,x,1,1,n);
}
}
return 0;
}