#include<fstream>
using namespace std;
int n, m, i, x[100003], A[100003], poz, val, sol, op, a, b;
void build(int st, int dr, int nod)
{
if(st==dr)
A[nod]=x[st];
else
{
int mij=st+(dr-st)/2;
build(st, mij, 2*nod);
build(mij+1, dr, 2*nod+1);
A[nod]=max(A[2*nod], A[2*nod+1]);
}
}
void update(int st, int dr, int nod, int poz, int val)
{
if(st==dr)
A[nod]=val;
else
{
int mij=st+(dr-st)/2;
if(poz<=mij)
update(st, mij, 2*nod, poz, val);
if(mij+1<=poz)
update(mij+1, dr, 2*nod+1, poz, val);
A[nod]=max(A[2*nod], A[2*nod+1]);
}
}
void querry(int st, int dr, int nod, int a, int b)
{
if(a<=st && dr<=b)
sol=max(sol, A[nod]);
else
{
int mij=st+(dr-st)/2;
if(a<=mij)
querry(st, mij, 2*nod, a, b);
if(b>=mij+1)
querry(mij+1, dr, 2*nod+1, a, b);
}
}
ifstream in("arbint.in");
ofstream out("arbint.out");
int main()
{
in>>n>>m;
for(i=1; i<=n; i++)
in>>x[i];
build(1, n, 1);
for(i=1; i<=n; i++)
{
in>>op;
if(op==0)
{
sol=-1;
in>>a>>b;
querry(1, n, 1, a, b);
out<<sol<<"\n";
}
else
{
in>>poz>>val;
update(1, n, 1, poz, val);
}
}
}