#include<iostream>
#include<fstream>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int ai[270001],maxx;
void build(int x, int st, int dr, int poz,int nr)
{
if(st==dr) //am gasit poz din ai
ai[x]=nr;
else
{
int m=(dr+st)/2;
if(m<poz)
build(2*x+1,m+1,dr,poz,nr);
else
build(2*x,st,m,poz,nr);
if(ai[2*x+1]>ai[2*x])
ai[x]=ai[2*x+1];
else
ai[x]=ai[2*x];
}
}
void get(int x,int st,int dr,int a,int b)
{
if(a<=st && dr<=b)
{
if(ai[x]>maxx)
maxx=ai[x];
return;
}
else
{
int m=st+(dr-st)/2;
if(a<=m)
get(2*x,st,m,a,b);
if(b>m)
get(2*x+1,m+1,dr,a,b);
}
}
int main()
{
int n,m,i,a,b,x;
bool y;
f>>n>>m;
for(i=1;i<=n;i++)
{
f>>x;
build(1,1,n,i,x);
}
for(i=1;i<=m;i++)
{
f>>y>>a>>b;
if(y==0)
{
maxx=0;
get(1,1,n,a,b);
g<<maxx<<'\n';
}
else
build(1,1,n,a,b);
}
return 0;
}