#include <fstream>
#define dmax 1000000010
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int v[400100];
void update(int nod, int poz, int x, int st, int dr)
{
if (st==dr) v[nod]=x;
else {
int m=st+(dr-st)/2;
if (poz<=m) update(2*nod,poz,x,st,m);
else update(2*nod+1,poz,x,m+1,dr);
v[nod]=max(v[2*nod],v[2*nod+1]);
}
}
int query(int nod, int st, int dr, int a, int b)
{
int x=0,y=0;
if (st>=a && dr<=b) return v[nod];
else {
int m=st+(dr-st)/2;
if (m>=a) x=query(2*nod,st,m,a,b);
if (m+1<=b) y=query(2*nod+1,m+1,dr,a,b);
return max(x,y);
}
}
int main()
{
int n,m,x,y,z;
fin>>n>>m;
for (int i=1;i<=n;i++)
{
fin>>x;
update(1,i,x,1,n);
}
for (int i=1;i<=m;i++)
{
fin>>x>>y>>z;
if (x==0) fout<<query(1,1,n,y,z)<<'\n';
if (x==1) update(1,y,z,1,n);
}
return 0;
}