#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m;
int tre[400041];
void update(int p, int v, int tp=1, int lt=1, int rt=n){
if(lt == rt){
tre[tp] = v;
}else{
int mid = (lt+rt)/2;
if(p <= mid){
update(p, v, tp*2, lt, mid);
}else{
update(p, v, tp*2+1, mid+1, rt);
}
tre[tp] = max(tre[tp*2], tre[tp*2+1]);
}
}
int query(int qlt, int qrt, int tp=1, int lt=1, int rt=n){
if(qlt <= lt && rt <= qrt){
return tre[tp];
}
int mid = (lt+rt)/2;
int r = -1;
if(qlt <= mid){
r = max(r, query(qlt, qrt, tp*2, lt, mid));
}
if(qrt > mid){
r = max(r, query(qlt, qrt, tp*2+1, mid+1, rt));
}
return r;
}
void buildit(int cp = 1, int lt = 1, int rt = n){
if(lt == rt){
fin >> tre[cp];
}else{
int mid = (lt+rt)/2;
buildit(cp*2, lt, mid);
buildit(cp*2+1, mid+1, rt);
tre[cp] = max(tre[cp*2], tre[cp*2+1]);
}
}
int main(){
fin >> n >> m;
buildit();
for(int i = 0; i < m; ++i){
int op, a, b;
fin >> op >> a >> b;
if(op == 0){
fout << query(a, b) << "\n";
}else{
update(a, b);
}
}
return 0;
}