#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n,m,c,a,b,v[400101];
void update(int val, int poz, int st, int dr, int poz2)
{
if(st==dr)
{
v[poz2]=val;
return;
}
int mij=(st+dr)/2;
if(mij>=poz)
update(val,poz,st,mij,poz2*2);
if(mij<poz)
update(val,poz,mij+1,dr,poz2*2+1);
v[poz2]=max(v[poz2*2],v[poz2*2+1]);
}
int query(int x, int y, int st, int dr, int poz2)
{
if(x<=st && y>=dr)
{
return v[poz2];
}
int mij=(st+dr)/2;
int lmax=0,rmax=0;
if(y>mij)
rmax=query(x,y,mij+1,dr,poz2*2+1);
if(x<=mij)
lmax=query(x,y,st,mij,poz2*2);
return max(lmax,rmax);
}
int main()
{
fin>>n>>m;
int ad=1;
while(ad<n)
ad*=2;
for(int i=ad;i<ad+n;i++)
fin>>v[i];
for(int i=ad-1;i>=1;i--)
v[i]=max(v[i*2],v[i*2+1]);
for(int i=1;i<=m;i++)
{
fin>>c>>a>>b;
if(!c)
{
fout<<query(a,b,1,ad,1)<<'\n';
}
else
{
update(b,a,1,ad,1);
}
}
return 0;
}