// arbori_intervale.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<cstdio>
using namespace std;
#define nMax 300001
int N, M, A, B, Max;
int Arb[nMax];
inline int Maxim(int a, int b)
{
if ( a > b )
return a;
return b;
}
void Actualizare(int vf, int st, int dr, int poz, int val)
{
if ( st == dr )
{
Arb[vf] = val;
return;
}
if ( poz <= (st+dr)/2 )
Actualizare ( 2*vf, st, (st+dr)/2, poz, val );
else
Actualizare ( 2*vf+1, (st+dr)/2+1, dr, poz, val );
Arb[vf] = Maxim ( Arb[2*vf], Arb[2*vf+1] );
}
void Interogare(int vf, int st, int dr, int S, int D)
{
if ( S <= st && dr <= D && Max < Arb[vf] )
{
Max = Arb[vf];
return;
}
if ( S <= (st+dr)/2 )
Interogare ( 2*vf, st, (st+dr)/2, S, D );
else if ( (st+dr)/2 < D )
Interogare ( 2*vf+1, (st+dr)/2+1, dr, S, D );
}
int _tmain(int argc, _TCHAR* argv[])
//int main()
{
freopen ( "arbint.in", "r", stdin );
freopen ( "arbint.out", "w", stdout );
scanf ( "%d %d", &N, &M );
int w;
for(int i=1; i<=N; i++)
{
scanf ( "%d", &w );
Actualizare ( 1, 1, N, i, w );
}
for(int i=1; i<=M; i++)
{
scanf ( "%d %d %d", &w, &A, &B );
if ( !w )
{
Max = -1;
Interogare ( 1, 1, N, A, B );
printf ( "%d\n", Max );
}
else
Actualizare ( 1, 1, N, A, B );
}
fclose(stdin);
fclose(stdout);
return 0;
}