#include <stdio.h>
using namespace std;
FILE *f=fopen("arbint.in","r");
FILE *g=fopen("arbint.out","w");
int n,x,a,b,c,maxf,val,pos,u,p,maxa[500000],i,mm;
int maxi(int a,int b)
{
if (a>b)return a;
else return b;
}
void update(int nod,int l,int r)
{
int m;
if (l==r) maxa[nod]=val;
else
{
m=(l+r)/2;
if (m>=pos)update(2*nod,l,m);
else update(2*nod+1,m+1,r);
maxa[nod]=maxi(maxa[2*nod],maxa[2*nod+1]);
}
}
void query(int nod,int l, int r)
{
int m;
if (p<=l && r<=u)
{
if (maxf<maxa[nod])maxf=maxa[nod];
return;
}
else
{
m=(l+r)/2;
if (p<=m)query(2*nod,l,m);
if (m<u)query(2*nod+1,m+1,r);
}
}
int main()
{
fscanf(f,"%d%d",&n,&mm);
for(i=1;i<=n;i++)
{
fscanf(f,"%d",&c);
pos=i;
val=c;
update(1,1,n);
}
for(i=1;i<=mm;i++)
{
fscanf(f,"%d%d%d",&x,&a,&b);
if (x==1)
{
pos=a;
val=b;
update(1,1,n);
}
else
{
maxf=-9999;
p=a;
u=b;
query(1,1,n);
fprintf(g,"%d\n",maxf);
}
}
fclose(g);
return 0;
}