#include <fstream>
#include <math.h>
using namespace std;
ifstream f ("arbint.in");
ofstream g ("arbint.out");
int AInt[400005];
void update (int poz, int val, int nod, int st, int dr)
{
if (st == dr)
{
AInt[nod] = val;
return;
}
int mij = (st + dr) / 2;
if (poz <= mij)
update (poz, val, 2 * nod, st, mij);
else
update (poz, val, 2 * nod + 1, mij + 1, dr);
AInt[nod] = max (AInt[2 * nod], AInt[2 * nod + 1]);
}
void cautare (int a, int b, int nod, int st, int dr, int& rez)
{
if (a <= st && dr <= b)
{
rez = max (rez, AInt[nod]);
return;
}
int mij = (st + dr) / 2;
if (a <= mij)
cautare (a, b, nod << 1, st, mij, rez);
if (mij < b)
cautare (a, b, (nod << 1) + 1, mij + 1, dr, rez);
}
int main()
{
int n, m, tip, a, b, nr, maxim;
f >> n >> m;
for (int i = 1; i <= n; i ++)
{
f >> nr;
update (i, nr, 1, 1, n);
}
for (int i = 1; i <= m; i ++)
{
f >> tip >> a >> b;
if (tip)
update (a, b, 1, 1, n);
else
{
maxim = 0;
cautare (a, b, 1, 1, n, maxim);
g << maxim << '\n';
}
}
f.close ();
g.close ();
return 0;
}