#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
int n, q, arb[400010], val;
void update(int nod, int left, int right, int pos, int val) {
if (left == right) {
arb[nod] = val;
return;
}
int mid = (left + right) / 2;
if (pos <= mid) update(2 * nod, left, mid, pos, val);
else update(2 * nod + 1, mid + 1, right, pos, val);
arb[nod] = max(arb[2 * nod], arb[2 * nod + 1]);
}
int query(int nod, int left, int right, int a, int b) {
if (a <= left && right <= b) return arb[nod];
int mid = (left + right) / 2;
int res = 0;
if (mid >= a) res = max(res, query(2 * nod, left, mid, a, b));
if(mid < b) res = max(res, query(2 * nod + 1, mid + 1, right, a, b));
return res;
}
int main() {
ios::sync_with_stdio(false);
in.tie(NULL), out.tie(NULL);
in >> n >> q;
for (int i = 0; i < n; i++) {
in >> val;
update(1, 1, n, i + 1, val);
}
while (q--) {
int t, a, b;
in >> t >> a >> b;
if (t == 0) {
out << query(1, 1, n, a, b) << '\n';
}
else {
update(1, 1, n, a, b);
}
}
return 0;
}