#include<conio.h>
#include<fstream.h>
long v[100005], a[270000];
void constr (long st, long dr, long b, long nod)
{
if (st==dr) a[nod]=v[b];
else
{
if (b<=(st+dr)/2) constr(st,(st+dr)/2,b,2*nod);
if (b>(st+dr)/2) constr((st+dr)/2+1,dr,b,2*nod+1);
if (a[nod]<a[2*nod]) a[nod]=a[2*nod];
if (a[nod]<a[2*nod+1]) a[nod]=a[nod*2+1];
}
}
long max (long st, long dr, long b1,long b2,long nod)
{
if (b1<=st && dr<=b2) return a[nod];
else
{
long mij=(st+dr)/2;
long max1=0, max2=0;
if (b1<=mij) max1=max(st,mij,b1,b2,2*nod);
if (b2>mij) max2=max(mij+1,dr,b1,b2,2*nod+1);
if (max1<max2) return max2;
else return max1;
}
}
void schimba (long st,long dr,long b,long nod)
{
if (st==dr) a[nod]=v[b];
else
{
long mij=(st+dr)/2;
if (b<=mij) schimba (st,mij,b,2*nod);
if (b>mij) schimba (mij+1,dr,b,2*nod+1);
if (a[2*nod]>a[2*nod+1]) a[nod]=a[2*nod];
else a[nod]=a[nod*2+1];
}
}
int main()
{
long n,i,m,nr;
ifstream f ("arbint.in");
f>>n>>m;
for (i=1;i<=n;i++)
{
f>>v[i];
constr(1,n,i,1);
}
ofstream g("arbint.out");
long a1,b;
for (i=1;i<=m;i++)
{
f>>nr>>a1>>b;
if (nr==1)
{
v[a1]=v[b];
schimba(1,n,a1,1);
}
else cout<<max(1,n,a1,b,1)<<endl;
}
f.close();
g.close();
return 0;
}