// https://www.infoarena.ro/problema/arbint
// arbore de intervale pe maxim, update punctual, indexat de la 1
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int MAXN = 100001;
int a[MAXN];
int t[4 * MAXN];
void build(int node, int l, int r) {
if (l == r) { t[node] = a[l]; return; }
int mid = (l + r) / 2;
build(2 * node, l, mid);
build(2 * node + 1, mid + 1, r);
t[node] = max(t[2 * node], t[2 * node + 1]);
}
void update(int node, int l, int r, int pos, int val) {
if (l == r) { t[node] = val; return; }
int mid = (l + r) / 2;
if (pos <= mid) update(2 * node, l, mid, pos, val);
else update(2 * node + 1, mid + 1, r, pos, val);
t[node] = max(t[2 * node], t[2 * node + 1]);
}
int query(int node, int l, int r, int ql, int qr) {
if (ql <= l && r <= qr) return t[node];
int mid = (l + r) / 2;
int res = 0; // valorile sunt >= 0
if (ql <= mid) res = max(res, query(2 * node, l, mid, ql, qr));
if (qr > mid) res = max(res, query(2 * node + 1, mid + 1, r, ql, qr));
return res;
}
int main() {
int n, m;
fin >> n >> m;
for (int i = 1; i <= n; i++)
fin >> a[i];
build(1, 1, n);
for (int k = 0; k < m; k++) {
int op, x, y;
fin >> op >> x >> y;
if (op == 0)
fout << query(1, 1, n, x, y) << '\n'; // 0 a b: maximul pe [a, b]
else
update(1, 1, n, x, y); // 1 a b: a[a] = b
}
return 0;
}