#include <algorithm>
using namespace std;
#define DIM 1<<17
int N, M;
int mx, arb[ DIM<<2 ];
inline int max( const int &a, const int &b ) {
if( a > b )
return a;
return b;
}
inline void query( const int &nod, const int &st, const int &dr, const int &a, const int &b ) {
int mij;
if( a <= st && dr <= b ) {
mx = max( mx, arb[ nod ] );
return;
}
mij = (st+dr) / 2;
if( a <= mij )
query( nod<<1, st, mij, a, b );
if( mij < b )
query( (nod<<1) + 1, mij+1, dr, a, b );
}
inline void update( const int &nod, const int &st, const int &dr, const int &poz, const int &val ) {
int mij;
if( st == dr ) {
arb[ nod ] = val;
return;
}
mij = (st+dr) / 2;
if( poz <= mij )
update( nod<<1, st, mij, poz, val );
else
update( (nod<<1) + 1, mij+1, dr, poz, val );
arb[ nod ] = max( arb[ nod<<1 ], arb[ (nod<<1) + 1 ] );
}
int main() {
freopen( "arbint.in", "r", stdin );
freopen( "arbint.out", "w", stdout );
int i, a, b, poz, tip, val;
scanf( "%d %d", &N, &M );
for( i = 1; i <= N; ++i ) {
scanf( "%d", &val );
update( 1, 1, N, i, val );
}
while( M-- ) {
scanf( "%d", &tip );
if( tip == 0 ) {
scanf( "%d %d", &a, &b );
mx = 0;
query( 1, 1, N, a, b );
printf( "%d\n", mx );
}
else {
scanf( "%d %d", &poz, &val );
update( 1, 1, N, poz, val );
}
}
return 0;
}