#include <iostream>
#include <fstream>
#define nmax 100005
using namespace std;
int arb[5*nmax];
int n, m, op, x, y, pos, val, sol;
void update(int nod, int st, int dr) {
if(st == dr) {
arb[nod] = val;
return;
}
int mij = (st + dr) >> 1;
if(pos <= mij) update(2*nod, st, mij);
else update(2*nod+1, mij+1, dr);
arb[nod] = max(arb[2*nod], arb[2*nod+1]);
}
void query(int nod, int st, int dr, int a, int b) {
//<nod> reprezinta intervalul [<st>, <dr>]
//trebuie sa updatez intervalul [<a>, <b>]
if(a <= st && b >= dr) {
sol = max(sol, arb[nod]);
return;
}
int mij = (st + dr) >> 1, maxim = 0;
if(a <= mij) query(2*nod, st, mij, a, b);
if(mij+1 <= b) query(2*nod+1, mij+1, dr, a, b);
}
int main() {
ifstream f("arbint.in");
ofstream g("arbint.out");
f>>n>>m;
for(int i=1; i<=n; i++) {
f>>x;
pos = i;
val = x;
update(1, 1, n);
}
for(int i=1; i<=m; i++) {
f>>op>>x>>y;
if(op == 1) {
pos = x;
val = y;
update(1, 1, n);
}
else {
sol = 0;
query(1, 1, n, x, y);
g<<sol<<"\n";
}
}
return 0;
}