#include <bits/stdc++.h>
const int MAX_N = 100000;
int aint[1 + MAX_N + MAX_N];
int query(int l, int r) {
int res = -1;
for (; l < r; l >>= 1, r >>= 1) {
if (l & 1) res = std::max(res, aint[l++]);
if (r & 1) res = std::max(res, aint[--r]);
}
return res;
}
void update(int p, int val) {
aint[p] = val;
for (p >>= 1; p >= 1; p >>= 1)
aint[p] = std::max(aint[p << 1], aint[(p << 1) ^ 1]);
}
int main() {
std::ifstream fin("arbint.in");
std::ofstream fout("arbint.out");
int N, M;
fin >> N >> M;
for (int i = 0; i < N; i++) fin >> aint[N + i];
for (int i = N - 1; i > 0; i--) aint[i] = std::max(aint[i << 1], aint[(i << 1) + 1]);
while (M-- > 0) {
int t, x, y;
fin >> t >> x >> y;
if (t == 0) {
fout << query(x - 1 + N, y + N) << "\n";
} else {
update((x - 1) + N, y);
}
}
return 0;
}