#include <iostream>
#include <fstream>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
///const int NMAX = 1e3;
const int INF = 1e9;
const int NMAX = 1e5;
int aint[NMAX * 4];
int poz, val;
void update( int st, int dr, int i ) {
if ( st == dr ) {
aint[i] = val;
return;
}
int mij = ( st + dr ) / 2;
if ( poz <= mij ) {
update( st, mij, i * 2 + 1 );
} else {
update( mij + 1, dr, i * 2 + 2 );
}
aint[i] = max( aint[i * 2 + 1], aint[i * 2 + 2] );
}
int query( int st, int dr, int a, int b, int i ) {
if ( a == st && dr == b ) {
return aint[i];
}
int mij = ( st + dr ) / 2;
if ( b <= mij ) {
return query( st, mij, a, b, i * 2 + 1 );
} else if ( a >= mij + 1 ) {
return query( mij + 1, dr, a, b, i * 2 + 2 );
}
return max( query( st, mij, a, mij, i * 2 + 1 ),
query( mij + 1, dr, mij + 1, b, i * 2 + 2 ) );
}
int main() {
ifstream fin( "arbint.in" );
ofstream fout( "arbint.out" );
int n, i, q;
fin >> n >> q;
for ( i = 0; i < n; i ++ ) {
fin >> val;
poz = i;
update( 0, n - 1, 0 );
}
for ( i = 0; i < q; i ++ ) {
int op, a, b;
fin >> op;
if ( op == 0 ) {
fin >> a >> b;
fout << query( 0, n - 1, a - 1, b - 1, 0 ) << '\n';
} else {
fin >> poz >> val;
poz --;
update( 0, n - 1, 0 );
}
}
return 0;
}