/*
* File: main.cpp
* Author: salexandru
*
* Created on January 14, 2011, 6:22 PM
*/
#include <fstream>
#include <cstdlib>
#define N_MAX 400011
using namespace std;
/*
*
*/
int Aint[N_MAX];
inline void Update( int index, int left, int right, int& xIndex, int& x )
{
if( left == right )
{
Aint[index]=x;
return;
}
int middle=(right+left)/2;
if( xIndex <= middle )
Update( 2*index, left, middle, xIndex, x );
else Update( 2*index+1, middle+1, right, xIndex, x );
Aint[index]=max( Aint[2*index], Aint[2*index+1] );
}
inline int Query( int index, int left, int right, int& a, int& b )
{
if( left >= a && right <= b )
return Aint[index];
int middle=(right+left)/2, m1=0, m2=0;
if( a <= middle )
m1=Query( 2*index, left, middle, a, b );
if( b > middle )
m2=Query( 2*index+1, middle+1, right, a, b );
return max( m1, m2 );
}
int main(int argc, char** argv)
{
int N, M, i, x, y;
ifstream in( "arbint.in" );
in>>N>>M;
for( i=1; i <= N; ++i )
{
in>>x;
Update( 1, 1, N, i, x );
}
ofstream out( "arbint.out" );
for( ; M; --M )
{
in>>i>>x>>y;
if( 0 == i )
out<<Query( 1, 1, N, x, y )<<'\n';
else Update( 1, 1, N, x, y );
}
return 0;
}