#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("arbint.in");
ofstream g ("arbint.out");
const int NMAX = 100000 + 1;
int n, m, sol;
int arbint[4 * NMAX];
void update(int nod, int st, int dr, int poz, int value) {
if (st == dr) {
arbint[nod] = value;
return;
}
int m = (st + dr) / 2;
if (poz <= m) update(2 * nod, st, m, poz, value);
else update(2 * nod + 1, m + 1, dr, poz, value);
arbint[nod] = max(arbint[2 * nod], arbint[2 * nod + 1]);
}
void query(int nod, int st, int dr, int a, int b) {
if (a <= st && dr <= b) {
sol = max(sol, arbint[nod]);
return;
}
int m = (st + dr) / 2;
if (a <= m) query(2 * nod, st, m, a, b);
if (m < b) query(2 * nod + 1, m + 1, dr, a, b);
}
void citeste() {
f >> n >> m;
int a;
for (int i = 1; i <= n; i++) {
f >> a;
update(1, 1, n, i, a);
}
}
void rezolva() {
int tip, a, b;
for (int i = 1; i <= m; i++) {
f >> tip >> a >> b;
if (tip == 0) {
sol = -1;
query(1, 1, n, a, b);
g << sol << '\n';
}
else update(1, 1, n, a, b);
}
}
int main() {
citeste();
rezolva();
return 0;
}