#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define DIM (100000<<2)+100
vector <int> MaxNod(DIM);
int n,m,Max,poz,val,St,Dr;
void Update(int nod,int st,int dr)
{
if(st==dr)
{
MaxNod[nod]=val;
return;
}
int m=(st+dr)>>1;
if(poz<=m)
Update((nod<<1),st,m);
else
Update((nod<<1)+1,m+1,dr);
MaxNod[nod]=max(MaxNod[(nod<<1)],MaxNod[(nod<<1)+1]);
}
void Get(int nod,int st,int dr)
{
if(St<=st&&dr<=Dr)
{
if(MaxNod[nod]>Max)
Max=MaxNod[nod];
return;
}
int m=(st+dr)>>1;
if(St<=m)
Get((nod<<1),st,m);
if(m<Dr)
Get((nod<<1)+1,m+1,dr);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
poz=i;val=x;
Update(1,1,n);
}
while(m--)
{
int op,x,y;
scanf("%d%d%d",&op,&x,&y);
if(op==1)
{
poz=x;val=y;
Update(1,1,n);
continue;
}
Max=-1;
St=x;Dr=y;
Get(1,1,n);
printf("%d\n",Max);
}
return 0;
}