#include <cstdio>
#include <algorithm>
using namespace std;
const int lg=100005;
int heap[4*lg], Maxim, a[lg], st, dr, n, m, poz, nou, x;
void add(int st, int dr, int nod)
{
if (st==dr)
{
heap[nod]=nou;
return;
}
int mij = (st+dr)/2;
if (poz <= mij)
add(st, mij, (nod<<1));
else
add(mij+1, dr, (nod<<1)+1);
heap[nod]=max(heap[(nod<<1)],heap[(nod<<1)+1]);
}
void build(int st, int dr, int nod)
{
if (st == dr)
{
heap[nod] = a[st];
return;
}
int mij = (st+dr)>>1;
build(st, mij, nod<<1);
build(mij + 1, dr, (nod<<1) + 1);
heap[nod] = max(heap[nod<<1] , heap[(nod<<1) + 1]);
}
void maxim(int st, int dr, int S, int D, int nod)
{
if (S <= st && D >= dr)
{
Maxim = max(Maxim, heap[nod]);
return ;
}
int mij = (st + dr) >>1;
if (S <= mij)
maxim(st, mij, S, D, (nod<<1));
if (D > mij)
maxim(mij+1, dr, S, D, (nod<<1)+1);
}
void citire()
{
scanf ("%d %d ", &n, &m);
for (int i=1; i<=n; i++)
scanf ("%d ",&a[i]);
build(1,n,1);
for (int i=1; i<=m; i++)
{
scanf ("%d ",&x);
if (x==0)
{
Maxim=0;
scanf ("%d %d ",&st, &dr);
maxim(1,n,st,dr,1);
printf ("%d\n",Maxim);
}
else
{
scanf ("%d %d ",&poz, &nou);
add(1,n,1);
}
}
}
int main()
{
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
citire();
return 0;
}