#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int NMax=100000;
int A[4*NMax+5], V[NMax+5];
int N,M,Max;
int left_son(int nod)
{
return nod*2;
}
int right_son(int nod)
{
return nod*2+1;
}
void Read()
{
fin>>N>>M;
for(int i=1;i<=N;++i)
{
fin>>V[i];
}
}
void Build(int Nod, int Left, int Right)
{
if(Left==Right)
{
A[Nod]=V[Left];
return;
}
int Mid=(Left+Right)/2;
Build(left_son(Nod),Left,Mid);
Build(right_son(Nod),Mid+1,Right);
A[Nod]=max(A[Nod*2],A[Nod*2+1]);
}
void Query(int Nod, int Left, int Right,int QLeft, int QRight)
{
if (QRight<Left || QLeft>Right) //nu intersecteaza, nu ne intereseaza
return;
if (QLeft>=Left && QRight<=Right) //este inclus, returnul ca sa nu mai coboram
{
Max=max(Max, A[Nod]);
return;
}
int Mid=(QLeft+QRight)/2;
Query(left_son(Nod), Left, Right, QLeft, Mid); //exploram stanga si dreapta in continuare
Query(right_son(Nod), Left, Right, Mid+1, QRight);
}
void Update(int Nod, int Left, int Right, int Pos, int v)
{
V[Pos]=v;
Build(1, 1, N);
}
int main()
{
Read();
Build(1,1,N);
for(int i=1;i<=M;++i)
{
int p,a,b;
fin>>p>>a>>b;
if(p==0)
{
Max=0;
Query(1,a, b, 1, N);
fout<<Max<<"\n";
}
else
{
Update(1,1,N,a,b);
}
}
return 0;
}