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