#include <iostream>
#include <stdio.h>
#define nn 6000000
using namespace std;
int arb[nn], n, m, maxx=-1;
void update(int poz, int val, int nod, int st, int dr)
{
if(st == dr)
{
arb[nod] = val;
return;
}
int mij = (st+dr)/2;
if(poz <= mij)
update( poz, val, 2*nod , st, mij );
else
update( poz, val, 2*nod+1, mij+1, dr );
arb[nod] = max(arb[2*nod], arb[2*nod+1]);
}
void cautare( int A, int B, int nod, int st, int dr)
{
if( A <= st && dr <= B )
{
if(arb[nod] > maxx)
maxx = arb[nod];
else;
}
else
{
int mij = (st+dr)/2;
if( A <= mij )
cautare( A,B, 2*nod, st, mij );
if( mij < B )
cautare( A,B, 2*nod+1, mij+1, dr );
}
}
void citire()
{
scanf("%d %d", &n, &m);
int x;
for(int i=1; i<=n ;i++)
{
scanf("%d", &x);
update(i, x, 1, 1, n);
}
int op, a, b;
for(int i=1;i<=m;i++)
{
scanf("%d %d %d", &op, &a, &b);
if( op == 1 )
update(a, b, 1, 1, n);
else
{
maxx=-1;
cautare(a,b, 1, 1, n);
printf("%d\n", maxx);
}
}
}
int main()
{
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
citire();
return 0;
}