// 22:58
#include <fstream>
using namespace std;
const int kMaxN = 1e5+5;
struct Aint {
int mx[3 * kMaxN];
void update(int node, int left, int right, int pos, int value) {
if (left == right) {
mx[node] = value;
return;
}
int mid = (left + right) / 2;
if (pos <= mid) {
update(2 * node, left, mid, pos, value);
} else {
update(2 * node + 1, mid + 1, right, pos, value);
}
mx[node] = max(mx[2 * node], mx[2 * node + 1]);
}
int query(int node, int left, int right, int c1, int c2) {
if (c1 <= left and right <= c2) {
return mx[node];
}
if (right < c1 or c2 < left) {
return 0;
}
int mid = (left + right) / 2;
return max(
query(2 * node, left, mid, c1, c2),
query(2 * node + 1, mid + 1, right, c1, c2)
);
}
};
int main() {
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n, q; cin >> n >> q;
Aint aint;
for (int i = 1; i <= n; i += 1) {
int x; cin >> x;
aint.update(1, 1, n, i, x);
}
while (q--) {
char c; cin >> c;
if (c == '0') {
int a, b; cin >> a >> b;
cout << aint.query(1, 1, n, a, b) << '\n';
} else {
int pos, x; cin >> pos >> x;
aint.update(1, 1, n, pos, x);
}
}
return 0;
}