#include <fstream>
#include <algorithm>
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define nmax 100000+5
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int heap[2*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()
{
int x, op, a, b;
fin >> n >> m;
FOR(i, 1, n)
{
fin >> x;
actualizare(1, 1, n, i, x);
}
FOR(i, 1, m)
{
fin >> op >> a >> b;
if (op == 0)
fout << interogare(1, 1, n, a, b) << '\n';
else
actualizare(1, 1, n, a, b);
}
return 0;
}