#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m;
int v[100005];
int arb[400005];
// construiesc arborele fiecare nod tine maximul pe intervalul [st dr]
void build(int nod, int st, int dr)
{
if (st == dr)
{
arb[nod] = v[st];
return;
}
int mij = (st + dr) / 2;
build(2 * nod, st, mij);
build(2 * nod + 1, mij + 1, dr);
arb[nod] = max(arb[2 * nod], arb[2 * nod + 1]);
}
// schimb valoarea de pe pozitia poz si actualizam maximele pe drum
void update(int nod, int st, int dr, int poz, int val)
{
if (st == dr)
{
arb[nod] = val;
return;
}
int mij = (st + dr) / 2;
if (poz <= mij)
update(2 * nod, st, mij, poz, val);
else
update(2 * nod + 1, mij + 1, dr, poz, val);
arb[nod] = max(arb[2 * nod], arb[2 * nod + 1]);
}
// intorc maximul de pe intervalul [a b]
int query(int nod, int st, int dr, int a, int b)
{
if (a <= st && dr <= b)
return arb[nod];
int mij = (st + dr) / 2;
int rezultat = 0;
if (a <= mij)
rezultat = max(rezultat, query(2 * nod, st, mij, a, b));
if (b > mij)
rezultat = max(rezultat, query(2 * nod + 1, mij + 1, dr, a, b));
return rezultat;
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; i++)
fin >> v[i];
build(1, 1, n);
for (int i = 0; i < m; i++)
{
int tip, a, b;
fin >> tip >> a >> b;
if (tip == 0)
fout << query(1, 1, n, a, b) << "\n";
else
update(1, 1, n, a, b);
}
return 0;
}