#include <stdio.h>
#include <algorithm>
#define n 1000001
using namespace std;
int heap[4*n], Minim=999999,a[n],nr,poz;
int m;
int M;
int A;
int B;
void build(int st, int dr, int nod)
{
if (st == dr)
{
heap[nod] = a[st];
return;
}
int mij = (st+dr)>>1;
build(st, mij, nod<<1);
build(mij + 1, dr, (nod<<1) + 1);
heap[nod] = max(heap[nod<<1] , heap[(nod<<1) + 1]);
}
void minim(int st, int dr, int S, int D, int nod)
{
if (S <= st && D >= dr)
{
Minim = max(Minim, heap[nod]);
return ;
}
int mij = (st + dr) >>1;
/*if(S >= st && S <= mij || D<=mij && D>=st)
{
minim(st,mij,S,D,nod<<1);
}
if(S >= mij && S<=dr || D <= dr && D>=mij)
{
minim(mij+1,dr,S,D,(nod<<1)+1);
}*/
if(D > mij)
minim(mij + 1 ,dr,S,D,(nod<<1)+1);
if(S <= mij)
minim(st,mij,S,D,(nod<<1));
}
void citire()
{
scanf("%d %d",&m,&M);
for(int i = 1 ; i <= m ; i++)
{
scanf("%d",&a[i]);
}
}
void add(int st, int dr, int nod)
{
if(st==dr)
{
heap[nod]=nr;
return;
}
int mij=(st+dr)/2;
if(poz<=mij)
add(st,mij,nod<<1);
else
add(mij+1,dr,(nod<<1)+1);
heap[nod] = max(heap[nod<<1] , heap[(nod<<1) + 1]);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
citire();
build(1,m,1);
for(int i=0;i<M;i++)
{
int x;
scanf("%d %d %d",&x,&A,&B);
if(x)
{
poz=A;
nr=B;
add(1,m,1);
}
else
{
Minim=-1;
minim(1,m,A,B,1);
printf("%d\n",Minim);
}
}
return 0;
}