#include <stdio.h>
#include <algorithm>
using namespace std;
#define nmax 400005
int arb[nmax];
void update( int index, int st, int dr, int xIndex, int x )
{
if( st == dr )
{
arb[index]=x;
return;
}
int mij = (dr+st)/2;
if( xIndex <= mij )
update( 2*index, st, mij, xIndex, x );
else update( 2*index+1, mij+1, dr, xIndex, x );
arb[index] = max( arb[2*index], arb[2*index+1] );
}
int query( int index, int st, int dr, int a, int b )
{
if( st >= a && dr <= b )
return arb[index];
int mij = (dr+st)/2, m1 = 0, m2 = 0;
if( a <= mij )
m1 = query( 2*index, st, mij, a, b );
if( b > mij )
m2 = query( 2*index+1, mij+1, dr, a, b );
return max(m1, m2);
}
int main ()
{
int N, M, i, x, y;
freopen("arbint.in","r",stdin);
scanf("%d%d", &N, &M);
for(i = 1; i <= N; ++i)
{
scanf("%d", &x);
update(1, 1, N, i, x);
}
freopen("arbint.out","w",stdout);
while (M--)
{
scanf("%d%d%d", &i, &x, &y);
if( 0 == i )
printf("%d\n", query(1, 1, N, x, y) );
else update(1, 1, N, x, y);
}
return 0;
}