#include <cstdio>
#define MAXN 1<<18
int AI[MAXN];
int N, M;
int poz, val;
int sol;
#define ns (nod << 1)
#define nd (ns + 1)
#define mj ((st + dr) >> 1)
void update (int nod, int st, int dr) {
if (st >= dr) AI[nod] = val;
else {
if (poz <= mj)
update (ns, st, mj);
else
update (nd, mj + 1, dr);
AI[nod] = AI[ns] > AI[nd] ? AI[ns] : AI[nd];
}
}
void query (int nod, int st, int dr, int a, int b) {
if (a <= st && dr <= b) sol = sol > AI[nod] ? sol : AI[nod];
else {
if (mj >= a) query (ns, st, mj, a, b);
if (mj < b) query (nd, mj + 1, dr, a, b);
}
}
int main () {
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
scanf ("%d %d", &N, &M);
for (int i = 1; i <= N; ++ i) {
scanf (" %d", &val);
poz = i;
update (1, 1, N);
}
int op;
for (; M; -- M) {
scanf (" %d %d %d", &op, &poz, &val);
if (op) update (1, 1, N);
else {
sol = 0;
query (1, 1, N, poz, val);
printf ("%d\n", sol);
}
}
}