#include <iostream>
#include <fstream>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int Aint[400001];
void update(int nod,int st,int dr,int val,int pos)
{
if(st==dr)
{
Aint[nod]=val;
}
else
{
int m=(st+dr)/2;
if(pos<=m) update(nod*2,st,m,val,pos);
else update(nod*2+1,m+1,dr,val,pos);
Aint[nod]=max(Aint[nod*2],Aint[nod*2+1]);
}
}
int querry(int nod,int st,int dr,int a,int b)
{
//if(b<st&&a>dr) return 0;
if(a<=st&&b>=dr) return Aint[nod];
else{
int m=(st+dr)/2;
int x1=0,x2=0;
if(a<=m) x1=querry(nod*2,st,m,a,b);
if(b>=m+1) x2=querry(nod*2+1,m+1,dr,a,b);
return max(x1,x2);
}
}
int main()
{
int n,m,x,p,y;
f>>n>>m;
for(int i=1; i<=n; i++)
{
f>>x;
update(1,1,n,x,i);
}
for(int i=1; i<=m; i++)
{
f>>p;
f>>x>>y;
if(p==0)
{
g<<querry(1,1,n,x,y)<<'\n';
}
else
{
update(1,1,n,y,x);
}
}
return 0;
}