#include <bits/stdc++.h>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
#define NMAX 100010
int N, M;
int arb[4 * NMAX], Max_Interv;
void Update(int nod, int st, int dr, int poz, int val) {
if (st == dr)
arb[nod] = val;
else {
int mij = (st + dr) / 2;
if (poz <= mij)
Update(2 * nod, st, mij, poz, val);
else
Update(2 * nod + 1, mij + 1, dr, poz, val);
arb[nod] = max(arb[2 * nod], arb[2 * nod + 1]);
}
}
void Query(int nod, int st, int dr,
const int & start,
const int & finish) {
if (start <= st && finish >= dr) {
Max_Interv = max(Max_Interv, arb[nod]);
return;
} else {
int mij = (st + dr) / 2;
if (start <= mij)
Query(2 * nod, st, mij, start, finish);
if (finish >= mij + 1)
Query(2 * nod + 1, mij + 1, dr, start, finish);
}
}
int main() {
f >> N >> M;
for (int i = 1; i <= N; i++) {
int X;
f >> X;
Update(1, 1, N, i, X);
}
for (int i = 1; i <= M; i++) {
int op, x, y;
f >> op >> x >> y;
if (op == 0) {
Max_Interv = 0;
Query(1, 1, N, x, y);
g << Max_Interv << "\n";
}
if (op == 1) {
Update(1, 1, N, x, y);
}
}
f.close();
g.close();
return 0;
}