#include <fstream>
#include <cstdlib>
#define N_MAX 200011
using namespace std;
typedef unsigned int uint;
uint Arbint[N_MAX];
inline uint _max( uint x, uint y ) { return x >= y ? x : y; }
inline void Update( uint vertex, uint left, uint right, uint& xIndex, uint& xValue )
{
if( left == right )
{
Arbint[vertex]=xValue;
}
else {
uint middle=(left+right)>>1, next=vertex<<1;
if( xIndex <= middle )
Update( next, left, middle, xIndex, xValue );
else Update( next|1, middle+1, right, xIndex, xValue );
Arbint[vertex]=_max( Arbint[next], Arbint[next|1] );
}
}
inline uint Query( uint vertex, uint left, uint right, uint& sInt, uint& eInt )
{
if( sInt <= left && eInt >= right )
return Arbint[vertex];
uint middle=(left+right)>>1, next=vertex<<1, a=0, b=0;
if( sInt <= middle )
a=Query( next, left, middle, sInt, eInt );
if( eInt > middle )
b=Query( next|1, middle+1, right, sInt, eInt );
return _max( a, b );
}
int main()
{
uint N, M, i, x, a, b, op;
ifstream in( "arbint.in" );
ofstream out( "arbint.out" );
in>>N>>M;
for( i=1; i <= N; ++i )
{
in>>x;
Update( 1, 1, N, i, x );
}
for( ; M; --M )
{
in>>op>>a>>b;
if( 1 == op )
Update( 1, 1, N, a, b );
else out<<Query( 1, 1, N, a, b )<<'\n';
}
return EXIT_SUCCESS;
}