#include <cstdio>
#include <iostream>
using namespace std;
int a[200010],v[100001];
int sol,x,y;
FILE *fin=fopen ("arbint.in","r");
FILE *fout=fopen ("arbint.out","w");
void build (int nod,int st,int dr){
int mid;
if (st==dr)
a[nod]=v[st];
else {
mid=(st+dr)/2;
build (2*nod,st,mid);
build (2*nod+1,mid+1,dr);
a[nod]=max(a[2*nod],a[2*nod+1]);
}
}
void update (int nod,int st,int dr){
int mid;
if (st==dr)
a[nod]=y;
else {
mid=(st+dr)/2;
if (x<=mid)
update (2*nod,st,mid);
else update (2*nod+1,mid+1,dr);
a[nod]=max(a[2*nod],a[2*nod+1]);
}
}
void query (int nod,int st,int dr){
int mid;
if (st>=x && y>=dr)
sol=max(sol,a[nod]);
else {
mid=(st+dr)/2;
if (x<=mid)
query (2*nod,st,mid);
if (mid+1<=y)
query (2*nod+1,mid+1,dr);
}
}
int main()
{
int n,m,i,cer;
fscanf (fin,"%d%d",&n,&m);
for (i=1;i<=n;i++)
fscanf (fin,"%d",&v[i]);
build (1,1,n);
for (i=1;i<=m;i++){
fscanf (fin,"%d%d%d",&cer,&x,&y);
if (cer==1)
update (1,1,n);
else {
sol=0;
query (1,1,n);
fprintf (fout,"%d\n",sol);
}
}
return 0;
}