#include <iostream>
#include <cstdio>
#include <algorithm>
#define nmax 100002
using namespace std;
int n,m,aib[4*nmax+2],poz,x,maxim;
void update(int st,int dr,int nod)
{
if (st==dr)
{
aib[nod]=x;
return;
}
int mij=(st+dr)/2;
if (mij<poz)
update(mij+1,dr,2*nod+1);
else
update(st,mij,2*nod);
aib[nod]=max(aib[2*nod],aib[2*nod+1]);
}
void query(int st,int dr,int nod)
{
if (x <=st && poz>=dr)
{
maxim=max(maxim,aib[nod]);
return;
}
int mij=(st+dr)/2;
if (poz>mij)
query(mij+1,dr,2*nod+1);
if (x<=mij)
query(st,mij,2*nod);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1;i<=n;++i)
{
scanf("%d",&x);
poz=i;
update(1,n,1);
}
for (int i=1;i<=m;++i)
{
int op;
scanf("%d%d%d",&op,&poz,&x);
if (op)
update(1,n,1);
else
{
maxim=-1;
swap(poz,x);
query(1,n,1);
printf("%d\n",maxim);
}
}
return 0;
}