#include <fstream>
#include <limits.h>
#include <vector>
#include <queue>
#include <string.h>
#define nMax 100001
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m;
int v[nMax], arb[4*nMax];
void read()
{
fin>>n>>m;
for(int i=1;i<=n;i++)
fin>>v[i];
}
void build(int node, int st, int dr)
{
if(st==dr)
{
arb[node]=v[st];
return;
}
int mid=st+(dr-st)/2;
build(2*node, st, mid);
build(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 Max=0;
if(st>=pozst&&dr<=pozdr)
return arb[node];
int mid=st+(dr-st)/2;
if(pozst<=mid)
Max=max(Max, query(2*node, st, mid, pozst, pozdr));
if(pozdr>mid)
Max=max(Max, query(2*node+1, mid+1, dr, pozst, pozdr));
return Max;
}
void upDate(int node, int st, int dr, int poz, int val)
{
if(st==dr)
{
arb[node]=val;
return;
}
int mid=st+(dr-st)/2;
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 a, b, c;
build(1, 1, n);
for(int i=1;i<=m;i++)
{
fin>>a>>b>>c;
if(a==0)
{
fout<<query(1, 1, n, b, c)<<'\n';
continue;
}
if(a==1)
{
upDate(1, 1, n, b, c);
continue;
}
}
}
int main()
{
read();
solve();
return 0;
}