#include <iostream>
#include <fstream>
using namespace std;
long a[100006],huh[200006],maxi,n,m,elem;
void init(int nod,int st,int dr)
{
if(st==dr)
huh[nod]=a[st];
else
{
int mij=(st+dr)/2;
init(2*nod,st,mij);
init(2*nod+1,mij+1,dr);
huh[nod]=max(huh[2*nod],huh[2*nod+1]);
}
}
void cauta(long nod,long st,long dr,long x,long y)
{
if(st>=x && dr<=y)
{
if(maxi<huh[nod])
maxi=huh[nod];
return;
}
else
{
long mij;
mij=(st+dr)/2;
if(x<=mij)
cauta(2*nod,st,mij,x,y);
if(y>mij)
cauta(2*nod+1,mij+1,dr,x,y);
}
}
void modifica(long nod,long st,long dr,long poz,long elem)
{
if(st==dr)
huh[nod]=elem;
else
{
long mij=(st+dr)/2;
if(poz<=mij)
modifica(2*nod,st,mij,poz,elem);
else
if(poz>mij)
modifica(2*nod+1,mij+1,dr,poz,elem);
huh[nod]=max(huh[2*nod],huh[2*nod+1]);
}
}
int main()
{
ifstream f("arbint.in");
ofstream g("arbint.out");
long x,y,i,cod;
f>>n>>m;
for(i=1;i<=n;i++)
f>>a[i];
init(1,1,n);
for(i=1;i<=m;i++)
{
f>>cod>>x>>y;
if(cod==0)
{
maxi=-1;
cauta(1,1,n,x,y);
g<<maxi<<'\n';
}
else
modifica(1,1,n,x,y);
}
f.close();
g.close();
return 0;
}