#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 ait[4*N_MAX], n, m;
int query(int poz, int lo, int hi, int st, int dr){
if(st >= lo and dr <=hi)
return ait[poz];
if(st > hi or dr < lo)
return -inf;
int mid = (st + dr)/2;
return max(query(poz*2, lo, hi, st, mid), query(poz*2 + 1, lo, hi, mid + 1, dr));
}
void update(int poz, int ind_upd, int new_val, int st, int dr){
if(st == dr and st == ind_upd){
ait[poz] = new_val;
return;
}
if(st > ind_upd or dr < ind_upd)
return;
int mid = (st + dr)/2;
update(poz*2, ind_upd, new_val, st, mid);
update(poz*2 + 1, ind_upd, new_val, mid + 1, dr);
ait[poz] = max(ait[poz*2], ait[poz*2+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 type, a, b; fin >> type >> a >> b;
if(type == 1)
update(1, a, b, 1, n);
else
fout << query(1, a, b, 1, n) << "\n";
}
return 0;
}
//Andrei Muntean, 2018