#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int NMAX = 1e5+2;
int n, m;
int v[NMAX], arb[4*NMAX];
void ReadFile()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&v[i]);
}
void build_heap(int node, int st, int dr)
{
int mid=st+(dr-st)/2;
if(st==dr)
{
arb[node]=v[st];
return;
}
build_heap(2*node, st, mid);
build_heap(2*node+1, mid+1, dr);
arb[node]=max(arb[2*node], arb[2*node+1]);
}
int query(int node, int st, int dr, int pozst, int pozdr)
{
int maxim=0;
int mid=st+(dr-st)/2;
if(st >= pozst && dr <= pozdr)
return arb[node];
if(pozst<=mid)
maxim=max(maxim, query(2*node, st, mid, pozst, pozdr));
if(pozdr>mid)
maxim =max(maxim, query(2*node+1, mid+1, dr, pozst, pozdr));
return maxim;
}
void update(int node, int st, int dr, int poz, int val)
{
int mid=st+(dr-st)/2;
if(st==dr)
{
arb[node]=val;
return;
}
if(poz <= mid)
update(2*node, st, mid, poz, val);
else
update(2*node+1, mid+1, dr, poz, val);
arb[node] = max(arb[2*node], arb[2*node+1]);
}
void Solve()
{
int x,y,z;
build_heap(1, 1, n);
for(int i=1;i<=m;i++)
{
scanf("%d%d%d",&x,&y,&z);
if(x==0)
{
printf("%d\n",query(1, 1, n, y, z));
continue;
}
if(x==1)
{
update(1, 1, n, y, z);
continue;
}
}
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
ReadFile();
Solve();
return 0;
}