#include <fstream>
using namespace std;
#define MAXN 100005
int v[MAXN * 4];
void update(int n, int st, int dr, const int &pos, const int &val) {
if (st == dr) {
v[n] = val;
} else {
int mij = (st + dr) / 2;
if (pos <= mij)
update(2 * n, st, mij, pos, val);
else
update(2 * n + 1, mij + 1, dr, pos, val);
v[n] = std::max(v[2 * n], v[2 * n + 1]);
}
}
int query(int n, int st, int dr, int pos1, int pos2) {
if (st == pos1 && dr == pos2) {
return v[n];
} else {
int ans = -1;
int mij = (st + dr) / 2;
if (pos1 <= mij)
ans = query(2 * n, st, mij, pos1, std::min(pos2, mij));
if (pos2 >= mij + 1)
ans = max(ans,
query(2 * n + 1, mij + 1, dr, std::max(pos1, mij + 1), pos2));
return ans;
}
}
int main() {
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m;
int i, x;
int op, a, b;
fin >> n >> m;
for (i = 1; i <= n; i++) {
fin >> x;
update(1, 1, n, i, x);
}
for (i = 0; i < m; i++) {
fin >> op >> a >> b;
if (op == 0) {
fout << query(1, 1, n, a, b) << '\n';
} else {
update(1, 1, n, a, b);
}
}
}