/**
* Code by Patrick Sava
* "Spiru Haret" National College of Bucharest
**/
# include "fstream"
# include "cstring"
# include "vector"
# include "queue"
# include "bitset"
# include "algorithm"
# include "map"
# include "set"
# include "unordered_map"
# include "deque"
# include "string"
# include "iomanip"
# include "cmath"
# include "stack"
# include "cassert"
const char IN [ ] = "arbint.in" ;
const char OUT [ ] = "arbint.out" ;
# define pb push_back
# define mp make_pair
# define FORN( a , b , c ) for ( register int a = b ; a <= c ; ++ a )
# define FORNBACK( a , b , c ) for ( register int a = b ; a >= c ; -- a )
using namespace std ;
const int MAX = 4e5;
ifstream cin ( IN ) ;
ofstream cout ( OUT ) ;
int arb [ MAX ] ;
inline 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 ] ) ;
}
inline int query ( int nod , int st , int dr , int a , int b )
{
if ( a <= st and dr <= b )
return arb [ nod ] ;
int mij = ( st + dr ) >> 1 ;
int max1 = 0 ;
int max2 = 0 ;
if ( a <= mij )
max1 = query ( nod * 2 , st , mij , a , b ) ;
if ( b > mij )
max2 = query ( nod * 2 + 1 , mij + 1 , dr , a , b ) ;
return max ( max1 , max2 ) ;
}
int main()
{
int n , m ;
cin >> n >> m ;
FORN ( i , 1 , n )
{
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 << query ( 1 , 1 , n , a , b ) << '\n' ;
}
else {
int a , b ;
cin >> a >> b ;
update ( 1 , 1 , n , a , b ) ;
}
}
return 0;
}