#include <fstream>
using namespace std;
ifstream fin( "arbint.in" );
ofstream fout( "arbint.out" );
const int NMAX = 100005;
int N, M;
int t[NMAX * 4];
void Update( int nod, int lf, int rg, int pos, int val ) {
if( lf == rg ) {
t[nod] = val;
return;
}
int mid = lf + ( rg - lf ) / 2;
if( pos <= mid ) Update( nod * 2, lf, mid, pos, val );
else Update( nod * 2 + 1, mid + 1, rg, pos, val );
t[nod] = max( t[nod * 2], t[nod * 2 + 1] );
}
int Query( int nod, int lf, int rg, int L, int R ) {
if( L <= lf && rg <= R ) return t[nod];
int mid = lf + ( rg - lf ) / 2;
int ans = 0;
if( L <= mid ) ans = Query( nod * 2, lf, mid, L, R );
if( mid < R ) ans = max( ans, Query( nod * 2 + 1, mid + 1, rg, L, R ));
return ans;
}
void Read()
{
fin >> N >> M;
for( int i = 1; i <= N; ++i ) {
int tmp;
fin >> tmp;
Update( 1, 1, N, i, tmp );
}
for( int i = 1; i <= M; ++i ) {
int q, a, b;
fin >> q >> a >> b;
if( q == 0 ) fout << Query( 1, 1, N, a, b ) << '\n';
else Update( 1, 1, N, a, b );
}
}
int main()
{
Read();
return 0;
}