#include <bits/stdc++.h>
#define NMAX 100000
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m, op, x, y, ans;
int arb[(NMAX << 2) + 2];
void build_tree(int st, int dr, int nod) {
if (st == dr) {
fin >> arb[nod];
return;
}
int mij = (st + dr) >> 1;
build_tree(st, mij, (nod << 1));
build_tree(mij + 1, dr, (nod << 1) + 1);
arb[nod] = max(arb[(nod << 1)], arb[(nod << 1) + 1]);
}
void update(int st, int dr, int nod, int poz, int val) {
if (st == dr) {
arb[nod] = val;
return;
}
int mij = (st + dr) >> 1;
if (poz <= mij) {
update(st, mij, (nod << 1), poz, val);
}
else {
update(mij + 1, dr, (nod << 1) + 1, poz, val);
}
arb[nod] = max(arb[(nod << 1)], arb[(nod << 1) + 1]);
}
void query(int st, int dr, int nod, int a, int b) {
if (a <= st && dr <= b) {
ans = max(ans, arb[nod]);
return;
}
int mij = (st + dr) >> 1;
if (a <= mij) {
query(st, mij, (nod << 1), a, b);
}
if (mij < b) {
query(mij + 1, dr, (nod << 1) + 1, a, b);
}
}
int main() {
ios_base::sync_with_stdio(false);
fin.tie(NULL);
fout.tie(NULL);
fin >> n >> m;
build_tree(1, n, 1);
while (m--) {
fin >> op >> x >> y;
if (op == 0) {
ans = -1;
query(1, n, 1, x, y);
fout << ans << '\n';
}
else {
update(1, n, 1, x, y);
}
}
return 0;
}