#include <cstdio>
#include <algorithm>
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define nmax 100000+5
using namespace std;
int heap[4*nmax];
int n, m;
void actualizare(int nod, int st, int dr, int poz, int x)
{
int mijl = (st + dr)/2;
if (st == dr)
heap[nod] = x;
else
{
if (poz <= mijl)
actualizare(2*nod, st, mijl, poz, x);
else
actualizare(2*nod+1, mijl+1, dr, poz, x);
heap[nod] = max(heap[2*nod], heap[2*nod+1]);
}
}
int interogare(int nod, int st, int dr, int a, int b)
{
int mijl = (st + dr)/2;
if (a <= st && dr <= b)
return heap[nod];
else
{
int x = 0, y = 0;
if (a <= mijl)
x = interogare(2*nod, st, mijl, a, b);
if (b >= mijl+1)
y = interogare(2*nod+1, mijl+1, dr, a, b);
return max(x, y);
}
}
int main()
{
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
int x, op, a, b;
scanf("%d%d", &n, &m);
FOR(i, 1, n)
{
scanf("%d", &x);
actualizare(1, 1, n, i, x);
}
FOR(i, 1, m)
{
scanf("%d%d%d", &op, &a, &b);
if (op == 0)
printf("%d\n", interogare(1, 1, n, a, b));
else
actualizare(1, 1, n, a, b);
}
return 0;
}