#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int t[400002];
void change(int nod, int st, int dr, int poz, int x)
{
if (poz < st || poz > dr)
return;
if (st == dr)
{
t[nod] = x;
return;
}
int mij = st + (dr - st) / 2;
change(2 * nod, st, mij, poz, x);
change(2 * nod + 1, mij + 1, dr, poz, x);
t[nod] = max(t[2 * nod], t[2 * nod + 1]);
}
int max_int(int nod, int st, int dr, int a, int b)
{
if (a > dr || b < st)
return 0;
if (a <= st && b >= dr)
return t[nod];
int mij = st + (dr - st) / 2;
return max(max_int(2 * nod, st, mij, a, b), max_int(2 * nod + 1, mij + 1, dr, a, b));
}
int main()
{
int x, op, a, b, m, n;
fin >> n >> m;
for (int i = 1; i <= n; i++)
{
fin >> x;
change(1, 1, n, i, x);
}
while (m--)
{
fin >> op >> a >> b;
if (op == 0)
fout << max_int(1, 1, n, a, b) << '\n';
else
change(1, 1, n, a, b);
}
return 0;
}