#include <cstdio>
#define DIM 10000
char buff[DIM];
int poz=0;
void citeste(int &numar)
{
numar = 0;
//cat timp caracterul din buffer nu e cifra ignor
while (buff[poz] < '0' || buff[poz] > '9')
//daca am "golit" bufferul atunci il umplu
if (++poz == DIM)
fread(buff,1,DIM,stdin),poz=0;
//cat timp dau de o cifra recalculez numarul
while ('0'<=buff[poz] && buff[poz]<='9')
{
numar = numar*10 + buff[poz] - '0';
if (++poz == DIM)
fread(buff,1,DIM,stdin),poz=0;
}
}
int v[100003],arb[400003];
int max(int a,int b)
{
if(a<b) return b;
return a;
}
void update(int s,int e,int nod,int pos)
{
if(s==e) arb[nod]=v[pos];
else
{
int mij=(s+e)/2;
if(pos<=mij) update(s,mij,2*nod,pos);
else update(mij+1,e,2*nod+1,pos);
arb[nod]=max(arb[2*nod],arb[2*nod+1]);
}
}
int query(int s,int e,int p1,int p2,int nod)
{
if(s==p1&&e==p2) return arb[nod];
else
{
int mij=(s+e)/2;
if(p2<=mij) return query(s,mij,p1,p2,2*nod);
else if(p1>mij) return query(mij+1,e,p1,p2,2*nod+1);
else return max(query(s,mij,p1,mij,2*nod),query(mij+1,e,mij+1,p2,2*nod+1));
}
}
using namespace std;
int main ()
{
freopen ("arbint.in","r",stdin);
freopen ("arbint.out","w",stdout);
int n,m,u=0;
citeste(n),citeste(m);
int a,b,c;
for (int i=1;i<=n;++i)
{
citeste(v[i]);
update(1,n,1,i);
}
for (int i=1;i<=m;++i)
{
citeste(a),citeste(b),citeste(c);
if (a==0)
{
printf("%d\n",query(1,n,b,c,1));
}
if (a==1)
{
v[b]=c;
update(1,n,1,b);
}
u=0;
}
}