#include <bits/stdc++.h>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
const int minInf = -1e9;
int aInt[4 * 100005];
// void build(int currentNode, int l, int r) {
// if(l == r) {
// aInt[currentNode] = a[l];
// return;
// }
// int mid = (l + r) / 2;
// build(2 * currentNode + 1, l, mid);
// build(2 * currentNode + 2, mid + 1 ,r);
// aInt[currentNode] = max(aInt[2 * currentNode + 1], aInt[2 * currentNode + 2]);
// }
int query(int currentNode, int l, int r, int a, int b) {
if(a <= l && b >= r) {
return aInt[currentNode];
}
int mid = (l + r) / 2;
if(a > r || b < l) {
return minInf;
}
return max(query(2 * currentNode + 1, l, mid, a, b), query(2 * currentNode + 2, mid + 1, r, a, b));
}
void update(int currentNode, int l, int r, int targetPoz, int newVal) {
if(l == r) {
aInt[currentNode] = newVal;
return;
}
int mid = (l + r) / 2;
if(targetPoz <= mid) {
update(2 * currentNode + 1, l, mid, targetPoz, newVal);
} else {
update(2 * currentNode + 2, mid + 1, r, targetPoz, newVal);
}
aInt[currentNode] = max(aInt[2 * currentNode + 1], aInt[2 * currentNode + 2]);
}
int main() {
ios::sync_with_stdio(false); in.tie(0); out.tie(0);
int n, m; in >> n >> m;
for(int i = 0; i < n; ++i) {
int x; in >> x;
update(0, 0, n - 1, i, x);
}
//build(0,0, n - 1);
for(int i = 1; i <= m; ++i) {
int x, a, b; in >> x >> a >> b;
if(x == 0) {
out << query(0, 0, n - 1, a - 1, b - 1) << '\n';
} else {
update(0, 0, n - 1, a - 1, b);
}
}
in.close(); out.close();
return 0;
}