#include <iostream>
#include <fstream>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
const int dim = 100001;
int arb[4 * dim];
void update(int node, int st, int dr, int pos, int val) {
if (st == dr) {
arb[node] = val;
return;
}
int m = (st + dr) / 2;
if (pos <= m) {
update(2 * node, st, m, pos, val);
} else {
update(2 * node + 1, m + 1, dr, pos, val);
}
arb[node] = max(arb[2 * node], arb[2 * node + 1]);
}
void query(int nod, int st, int dr, int a, int b, int &maxim) {
if (a <= st && dr <= b) {
maxim = max(maxim, arb[nod]);
return;
}
int m = (st + dr) / 2;
if (a <= m) {
query(2 * nod, st, m, a, b, maxim);
}
if (b >= m + 1) {
query(2 * nod + 1, m + 1, dr, a, b, maxim);
}
}
int main()
{
int n, q, i, x, t, a, b, maxim;
in >> n >> q;
for (i = 1; i <= n; i++) {
in >> x;
update(1, 1, n, i, x);
}
for (i = 1; i <= q; i++) {
in >> t >> a >> b;
if (t == 0) {
maxim = -1;
query(1, 1, n, a, b, maxim);
out << maxim << "\n";
} else {
update(1, 1, n, a, b);
}
}
return 0;
}