#include <bits/stdc++.h>
#define N 100008
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, q;
int v[N];
int T[4 * N];
void update( int left, int right, int nod, int poz, int x )
{
if( left == right )
T[nod] = x;
else
{
int pivot = ( left + right ) / 2;
if( poz <= pivot )
update( left, pivot, nod << 1, poz, x );
else
update( pivot + 1, right, nod << 1|1, poz, x );
T[nod] = max( T[nod << 1], T[nod << 1|1] );
}
}
int query( int left, int right, int nod, int i, int j )
{
if( i <= left && right <= j )
return T[nod];
int a = 0, b = 0;
int pivot = ( left + right ) / 2;
if( i <= pivot )
a = query( left, pivot, nod << 1, i, j );
if( j > pivot )
b = query( pivot + 1, right, nod << 1|1, i, j );
return max( a, b );
}
void Citire()
{
int i;
fin >> n >> q;
for( i=1; i<=n; i++ )
{
fin >> v[i];
update( 1, n, 1, i, v[i] );
}
}
void Rezolvare()
{
int i;
int task;
int x, y;
for( i=1; i<=q; i++ )
{
fin >> task >> x >> y;
if( task ) update( 1, n, 1, x, y );
else fout << query( 1, n, 1, x, y ) << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
Citire();
Rezolvare();
//cout << sizeof( Lee ) / 1024.0 / 1024.0;
return 0;
}