#include<iostream>
#include<fstream>
using namespace std;
long long int st[400005];
void update(int node,int from,int to,int pos,long long val)
{
if(to==from)
{
st[node]=val;
return;
}
int mid=(from+to)/2;
if(pos<=mid)
update(node*2,from,mid,pos,val);
else
update(node*2+1,mid+1,to,pos,val);
st[node]=max(st[node*2],st[node*2+1]);
}
int query(int node,int from,int to,int qlf,int qrt)
{
int smax=0;
if(qlf<=from&&qrt>=to)
{
return st[node];
}
int mid=(from+to)/2;
if(qlf<=mid)
{
int s=query(node*2,from,mid,qlf,qrt);
smax=max(smax,s);
}
if(qrt>=mid+1)
{
int s=query(node*2+1,mid+1,to,qlf,qrt);
smax=max(smax,s);
}
return smax;
}
long long int m,n,x,y,z;
int main()
{
ifstream f("arbint.in");
ofstream g("arbint.out");
f>>n>>m;
for(int i=1;i<=n;i++)
{
f>>x;
update(1,1,n,i,x);
}
for(int i=1;i<=m;i++)
{
f>>x>>y>>z;
if(x==1)
update(1,1,n,y,z);
if(x==0)
g<<query(1,1,n,y,z)<<endl;
}
}