#include <iostream>
#include <fstream>
using namespace std;
#ifdef LOCAL
ifstream f("input.txt");
#define g cout
#else
ifstream f("adunare.in");
ofstream g("adunare.out");
#endif
const int mxN = 100005;
int n, m;
int a[mxN];
int arb[4 * mxN];
int t, x, y;
void build(int st, int dr, int nod) {
if (st == dr) {
arb[nod] = a[st];
return;
}
int mij = (st + dr) / 2;
build(st, mij, nod * 2);
build(mij + 1, dr, nod * 2 + 1);
arb[nod] = max(arb[nod * 2], arb[nod * 2 + 1]);
}
void build() {
build(1, n, 1);
}
void update(int pos, int val, int st, int dr, int nod) {
if (st == dr && st == pos) {
arb[nod] = val;
return;
}
int mij = (st + dr) / 2;
if (pos <= mij)
update(pos, val, st, mij, nod * 2);
else
update(pos, val, mij + 1, dr, nod * 2 + 1);
arb[nod] = max(arb[nod * 2], arb[nod * 2 + 1]);
}
void update(int pos, int val) {
update(pos, val, 1, n, 1);
}
int query(int x, int y, int st, int dr, int nod) {
if (x <= st && dr <= y)
return arb[nod];
int mij = (st + dr) / 2;
if (x <= mij && mij + 1 <= y)
return max(query(x, y, st, mij, nod * 2), query(x, y, mij + 1, dr, nod * 2 + 1));
if (x <= mij)
return query(x, y, st, mij, nod * 2);
return query(x, y, mij + 1, dr, nod * 2 + 1);
}
int query(int x, int y) {
return query(x, y, 1, n, 1);
}
int main() {
f >> n >> m;
for (int i = 1; i <= n; i++)
f >> a[i];
build();
for (int i = 1; i <= m; i++) {
f >> t >> x >> y;
if (t == 0)
g << query(x, y) << '\n';
else
update(x, y);
}
return 0;
}