#include<cstdio>
#define nmax 100001
using namespace std;
int N,M,pos,Val,maxim,st,dr;
int Arb[5*nmax];
int Big(int A,int B);
void read();
void solve();
void Query(int,int,int);
void Update(int,int,int);
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
read();
solve();
return 0;
}
int Big(int A,int B)
{
return (A>B?A:B);
}
void read()
{
int i;
scanf("%d%d",&N,&M);
for (i=1;i<=N;++i)
{
scanf("%d",&Val);
pos=i;
Update(1,1,N);
}
}
void solve()
{
int i,c;
for (i=1;i<=M;++i)
{
scanf("%d",&c);
if (c)
{
scanf("%d%d",&pos,&Val);
Update(1,1,N);
}
else
{
maxim=-1;
scanf("%d%d",&st,&dr);
Query(1,1,N);
printf("%d\n",maxim);
}
}
}
void Update(int nod,int s,int d)
{
int mij;
if (s==d)
{
Arb[nod]=Val;
return ;
}
mij=(s+d)/2;
if (pos<=mij) Update(2*nod,s,mij);
else Update(2*nod+1,mij+1,d);
Arb[nod]=Big(Arb[nod*2],Arb[nod*2+1]);
}
void Query(int nod,int s,int d)
{
int mij;
if (st<=s&&d<=dr)
{
maxim=Big(maxim,Arb[nod]);
return;
}
mij=(s+d)/2;
if (st<=mij) Query(2*nod,s,mij);
if (mij<dr) Query(2*nod+1,mij+1,d);
}