#include<bits/stdc++.h>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
#define LEN 100000
long long aint[LEN * 5];
void update(int st, int dr, int ind, int poz, int x) {
if(poz < st || poz > dr) {
return;
}
if(st > dr) {
return;
}
if(st == dr) {
aint[ind] = x;
return;
}
int mi = (st + dr) / 2;
update(st, mi, ind * 2, poz, x);
update(mi + 1, dr, ind * 2 + 1, poz, x);
aint[ind] = max(aint[ind * 2], aint[ind * 2 + 1]);
}
int maxint(int st, int dr, int cst, int cdr, int ind) {
if(st == dr) {
return aint[ind];
}
int mi = (st + dr) / 2;
if(cdr <= mi) {
return maxint(st, mi, cst, cdr, ind * 2);
}
if(cst >= mi + 1) {
return maxint(mi + 1, dr, cst, cdr, ind * 2 + 1);
}
int rezst = maxint(st, mi, cst, mi, ind * 2);
int rezdr = maxint(mi + 1, dr, mi + 1, cdr, ind * 2 + 1);
return max(rezst, rezdr);
}
int main() {
int n, q;
fin >> n >> q;
for(int i = 1; i <= n; i++) {
int x;
fin >> x;
update(1, n, 1, i, x);
}
for(int i = 1; i <= q; i++) {
int op, a, b;
fin >> op >> a >> b;
if(op == 1) {
update(1, n, 1, a, b);
} else {
fout << maxint(1, n, a, b, 1) << "\n";
}
}
fin.close();
fout.close();
return 0;
}