#include<cstdio>
#include<algorithm>
using namespace std;
FILE *f=fopen("arbint.in","r");
FILE *g=fopen("arbint.out","w");
int a[300001];int n,m,maxx,l,r,x,poz;
void update(int i,int left,int right)
{
if(left!=right)
{
int m=(left+right)/2;
if(poz<=m)
update(2*i,left,m);
else
update(2*i+1,m+1,right);
a[i]=max(a[2*i],a[2*i+1]);
}
else
a[i]=x;
}
void maxim(int i,int left,int right)
{
if(left>=l&&right<=r)
{
maxx=max(maxx,a[i]);
return ;
}
int m=(left+right)/2;
if(r<=m)
maxim(2*i,left,m);
else
if(l>m)
maxim(2*i+1,m+1,right);
else{
maxim(2*i,left,m);
maxim(2*i+1,m+1,right);
}
}
int main()
{
int y;
int i,cer;
fscanf(f,"%d%d",&n,&m);
for(i=1;i<=n;i++)
{
fscanf(f,"%ld",&x);
poz=i;
update(1,1,n);
}
for(i=1;i<=m;i++)
{
fscanf(f,"%d%d%ld",&cer,&x,&y);
if(cer==1)
{
poz=x;
x=y;
update(1,1,n);
}
else
{
maxx=-1;
l=x;
r=y;
maxim(1,1,n);
fprintf(g,"%ld\n",maxx);
}
}
return 0;
}