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