#include <stdio.h>
#include <fstream>
#define NMAX 100001
using namespace std;
int N;
int Arb[4 * NMAX];
int Maxx;
void getMax(int Poz, int L, int R, int from, int to) {
if (from <= L && R <= to) {
if (Arb[Poz] > Maxx) {
Maxx = Arb[Poz];
}
return;
}
int M = (L + R) / 2;
if (from <= M) {
getMax(2 * Poz, L, M, from, to);
}
if (to >= M + 1) {
getMax(2 * Poz + 1, M + 1, R, from, to);
}
}
void update(int Poz, int L, int R, int PozUpdate, int Val) {
if (L == R) {
Arb[Poz] = Val;
return;
}
int M = (L + R) / 2;
if (PozUpdate <= M) {
update(2 * Poz, L, M, PozUpdate, Val);
} else {
update(2 * Poz + 1, M + 1, R, PozUpdate, Val);
}
int p1, p2;
p1 = Arb[2 * Poz];
p2 = Arb[2 * Poz + 1];
Arb[Poz] = p1 > p2 ? p1 : p2;
}
void read_() {
int M, cmd, a, b, aux;
ifstream fin("arbint.in");
fin >> N >> M;
for (int i = 1; i <= N; i++) {
fin >> aux;
update(1, 1, N, i, aux);
}
for (int i = 0; i < M; i++) {
fin >> cmd >> a >> b;
if (!cmd) {
Maxx = 0;
getMax(1, 1, N, a, b);
printf("%d\n", Maxx);
} else {
update(1, 1, N, a, b);
}
}
fin.close();
}
int main() {
freopen("arbint.out", "w", stdout);
read_();
return 0;
}