#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("arbint.in"); ofstream g("arbint.out");
int Arb[400004],n,m,Max;
void update(int nod, int st, int dr, int p, int x) {
if (st == dr) {
Arb[nod] = x;
return;
}
int mij = (st + dr) / 2;
if (p <= mij) {
update(2*nod,st,mij,p,x);
}
else {
update(2*nod+1,mij+1,dr,p,x);
}
Arb[nod] = max(Arb[nod*2],Arb[nod*2+1]);
}
void query(int nod, int st, int dr, int x, int y) {
if (x <= st && y >= dr) {
Max = max(Max,Arb[nod]);
return;
}
int mij = (st + dr) / 2;
if (x <= mij) {
query(nod*2,st,mij,x,y);
}
if (y > mij) {
query(nod*2+1,mij+1,dr,x,y);
}
}
int main() {
int i,x,y,c;
f>>n>>m;
for(i = 1; i <= n; ++i) {
f>>x;
update(1,1,n,i,x);
}
for(i = 1; i <= m; ++i) {
f>>c>>x>>y;
if (c) {
update(1,1,n,x,y);
}
else {
Max = 0;
query(1,1,n,x,y);
g<<Max<<'\n';
}
}
return 0;
}