#include <bits/stdc++.h>
#define DIM 100010
using namespace std;
ifstream f ("arbint.in") ;
ofstream g ("arbint.out") ;
int arb[4*DIM+10] , N , M ;
int st, dr , a ,b , pozitie , valoare ,cer;
int Max ;
void Query(int nod ,int st ,int dr,int a,int b) ;
void Update(int nod ,int st , int dr) ;
void Update(int nod ,int st ,int dr)
{
if (st == dr)
arb[nod] = valoare;
else
{
int mij = (st + dr) / 2;
if (pozitie <= mij) Update(2*nod,st,mij) ;
else Update(2*nod+1,mij+1,dr) ;
arb[nod] = max(arb[2*nod] , arb[2*nod+1]) ;
}
}
void Query(int nod ,int st , int dr, int a, int b)
{
int r1=-1, r2=-1;
if (a <= st && dr <= b)
{
if (arb[nod] > Max) Max = arb[nod];
}
else
{
int mij = (st+dr) / 2;
if (a <= mij) Query(2*nod,st,mij,a,b) ;
if (b > mij)
Query(2*nod+1,mij+1,dr,a,b) ;
}
}
int main()
{
f >> N >> M ;
int x;
// Construieste arborele
//for (int i = 1 ; i <= 2 *N - 1 ; ++i)
//g << arb[i] << ' ' ;
for (int i = 1 ; i <= N ; ++i)
{
f >> x;
pozitie = i;
valoare = x;
Update(1,1,N) ;
}
for (int i = 1 ; i <= M ; ++i)
{
f >> cer >> a >> b;
if (cer == 0)
{
Max = -1;
Query(1,1,N,a,b);
g << Max << '\n';
}
else
{
pozitie = a;
valoare = b;
Update(1,1,N);
}
}
return 0;
}