#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
ifstream fin("hanoi.in");
ofstream fout("hanoi.out");
const int N = 1 << 18;
const int INF = 1 << 30;
int arb[N];
void constr(int p, int st, int dr) {
if (st == dr) {
fin >> arb[p];
}
else {
int m = (st + dr) / 2, fs = 2 * p, fd = 2 * p + 1;
constr(fs, st, m);
constr(fd, m + 1, dr);
arb[p] = max(arb[fs], arb[fd]);
}
}
int maxx(int p, int st, int dr, int a, int b) {
if (a <= st && dr <= b) {
return arb[p];
}
int m = (st + dr) / 2, fs = 2 * p, fd = 2 * p + 1;
int rez_st = -INF, rez_dr = -INF;
if (a <= m) {
rez_st = maxx(fs, st, m, a, b);
}
if (m + 1 <= b) {
rez_dr = maxx(fd, m + 1, dr, a, b);
}
return max(rez_st, rez_dr);
}
void actualizare(int p, int st, int dr, int poz, int val) {
if (st == dr) {
arb[p] = val;
return;
}
int m = (st + dr) / 2, fs = 2 * p, fd = 2 * p + 1;
if (poz <= m) {
actualizare(fs, st, m, poz, val);
}
else {
actualizare(fd, m + 1, dr, poz, val);
}
arb[p] = max(arb[fs], arb[fd]);
}
int main()
{
int n, nq;
fin >> n >> nq;
constr(1, 1, n);
for (int i = 1; i <= nq; i++) {
int c;
fin >> c;
if (c == 0) {
int a, b;
fin >> a >> b;
fout << maxx(1, 1, n, a, b) << "\n";
}
else{
int poz, val;
fin >> poz >> val;
actualizare(1, 1, n, poz, val);
}
}
return 0;
}