#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int aint[4000005];
int n,m;
void Update(int nod, int st, int dr, int poz, int val)
{
if (st == dr)
{
aint[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);
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
}
int Query(int nod, int st, int dr, int x, int y)
{
if (x <= st && dr <= y) return aint[nod];
int mij = (st + dr) / 2;
int ph1 = -1, ph2 = -1;
if (x <= mij) ph1 = Query(2 * nod, st, mij, x, mij);
if (mij < y) ph2 = Query(2 * nod + 1, mij + 1, dr, mij + 1, y);
return max(ph1, ph2);
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; i++)
{
int x;
fin >> x;
Update(1, 1, n, i, x);
}
for (int i = 1; i <= m; i++)
{
int op, x, y;
cin >> op >> x >> y;
if (op == 0) fout << Query(1,1,n,x,y) << "\n";
else Update(1,1,n,x,y);
}
}