#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
const int maxn = 1e5 + 5;
int T[maxn << 2];
int n, q, maxx;
void Update(int node, int st, int dr, int pos, int val) {
if (st == dr) {
T[node] = val;
return;
}
int mid = (st + dr) >> 1;
if (pos <= mid) Update(node << 1, st, mid, pos, val);
if (pos > mid) Update(node << 1 | 1, mid + 1, dr, pos, val);
T[node] = max(T[node << 1], T[node << 1 | 1]);
}
void Query(int node, int st, int dr, int inc, int sf) {
if (inc <= st && dr <= sf) {
maxx = max(maxx, T[node]);
return;
}
int mid = (st + dr) >> 1;
if (inc <= mid) Query(node << 1, st, mid, inc, sf);
if (sf > mid) Query(node << 1 | 1, mid + 1, dr, inc, sf);
}
int main() {
ios_base :: sync_with_stdio(false);
fin >> n >> q;
for (int i = 1; i <= n; i++) {
int x;
fin >> x;
Update(1, 1, n, i, x);
}
while (q--) {
int op, x, y;
fin >> op >> x >> y;
if (op == 1) {
Update(1, 1, n, x, y);
} else {
maxx = 0;
Query(1, 1, n, x, y);
fout << maxx << "\n";
}
}
return 0;
}