#include <bits/stdc++.h>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout("arbint.out");
const int N_MAX = 100000 + 5;
const int inf = 0x3f3f3f3f;
int n, m, ait[4*N_MAX];
int query (int poz, int lo, int hi, int st, int dr){
if(st >= lo and dr <=hi) // daca [st, dr] este inclus in [lo,hi]
return ait[poz];
if(st > hi or dr < lo) // daca [st, dr] nu are nici un elm comun cu [lo,hi]
return -inf;
///altfel, [st,dr] include cel putin un elm din [lo,hi] si trebuie desfacut
int mid = (dr + st)/2;
return max(
query(poz*2, lo, hi, st, mid),
query(poz*2+1, lo, hi, mid+1, dr)
);
}
void update(int poz, int upd_ind, int new_val, int st, int dr){
if(st == dr and st == upd_ind){ // daca [st,dr] are un singur element (st == dr) si acel element este upd_ind, fa update-ul
ait[poz] = new_val;
return;
}
if(st > upd_ind or dr < upd_ind) // daca upd_ind nu se afla in [st,dr]
return;
/// altfel sigur upd_ind se afla in interval si intervalul trebuie desfacut
int mid = (dr + st)/2;
update(poz * 2, upd_ind,new_val, st, mid);
update(poz * 2 + 1, upd_ind,new_val, mid+1, dr);
// dupa ce s-au actualizat toate pozitile de sub, se actualizeaza si cea curenta
ait[poz] = max(ait[2*poz], ait[2*poz + 1]);
}
int main() {
fin >> n >> m;
for(int i = 1, nr; i<=n; ++i){
fin >> nr;
update(1, i, nr, 1, n);
}
while(m--){
int task, a, b;
fin >> task >> a >> b;
if(task == 1)
update(1, a, b, 1, n);
else
fout << query(1, a, b, 1, n) << "\n";
}
return 0;
}
//Andrei Muntean, 2018