#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int n,m,Max;
vector <int> tree((100000<<2)+500);
void Update(int nod,int st,int dr,int poz,int val)
{
if(st==dr)
{
tree[nod]=val;
return;
}
int m=(st+dr)>>1;
if(poz<=m)
Update((nod<<1),st,m,poz,val);
else
Update((nod<<1)+1,m+1,dr,poz,val);
tree[nod]=max(tree[(nod<<1)],tree[(nod<<1)+1]);
}
void GetMax(int nod,int st,int dr,int a,int b)
{
if(a<=st&&dr<=b)
{
Max=max(Max,tree[nod]);
return ;
}
int m=(st+dr)>>1;
if(a<=m)
GetMax((nod<<1),st,m,a,b);
if(m<b)
GetMax((nod<<1)+1,m+1,dr,a,b);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
Update(1,1,n,i,x);
}
for(;m;m--)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
if(x)
{
Update(1,1,n,y,z);
}
else
{
Max=0;
GetMax(1,1,n,y,z);
printf("%d\n",Max);
}
}
return 0;
}