#include <fstream>
using namespace std;
ifstream cin ( "arbint.in" ) ;
ofstream cout ( "arbint.out" ) ;
const int MAX = 1e5 + 14 ;
int arb [ MAX * 4 ] ;
void update ( int nod , int st , int dr , int pos , int val )
{
if ( st == dr ) {
arb [ nod ] = val ;
return ;
}
int mij = ( st + dr ) >> 1 ;
if ( pos <= mij ) {
update ( nod * 2 , st , mij , pos , val ) ;
}
else {
update ( nod * 2 + 1 , mij + 1 , dr , pos , val ) ;
}
arb [ nod ] = max ( arb [ nod * 2 ] , arb [ nod * 2 + 1 ] ) ;
}
int Q ( int nod , int st , int dr , int a , int b )
{
if ( a <= st and dr <= b )
return arb [ nod ] ;
int mij = ( st + dr ) / 2 ;
int global = 0 ;
if ( a <= mij ) {
global = max ( global , Q ( nod * 2 , st , mij , a , b ) ) ;
}
if ( b > mij ) {
global = max ( global , Q ( nod * 2 + 1 , mij + 1 , dr , a , b ) ) ;
}
return global ;
}
int main()
{
int n , m ;
cin >> n >> m ;
for ( int i = 1 ; i <= n ; ++ i )
{
int x ;
cin >> x ;
update ( 1 , 1 , n , i , x ) ;
}
while ( m -- )
{
int tip ;
cin >> tip ;
if ( tip == 0 ) {
int a , b ;
cin >> a >> b ;
cout << Q ( 1 , 1 , n , a , b ) << '\n' ;
}
else {
int pos , val ;
cin >> pos >> val ;
update ( 1 , 1 , n , pos , val ) ;
}
}
return 0;
}