#include <bits/stdc++.h>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int t[400001], a[100001];
int N, M;
void build(int a[], int v, int tl, int tr){
if(tl == tr){
t[v] = a[tl];
}else{
int tm = (tl + tr) >> 1;
build(a, v * 2, tl, tm);
build(a, v * 2 + 1, tm + 1, tr);
t[v] = max(t[v * 2], t[v * 2 + 1]);
}
}
int get_max(int v, int tl, int tr, int l, int r){
if(l > r)
return INT_MIN;
if(l == tl && r == tr)
return t[v];
int tm = (tl + tr) >> 1;
return max(get_max(v * 2, tl, tm, l, min(r, tm)), get_max(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int v, int tl, int tr, int pos, int new_val){
if(tl == tr){
t[v] = new_val;
}else{
int tm = (tl + tr) >> 1;
if(pos <= tm)
update(v * 2, tl, tm, pos, new_val);
else
update(v * 2 + 1, tm + 1, tr, pos, new_val);
t[v] = max(t[2 * v], t[2 * v + 1]);
}
}
int main(){
f >> N >> M;
for(int i = 1;i <= N;i++)
f >> a[i];
build(a, 1, 1, N);
while(M--){
int op, a, b;
f >> op >> a >> b;
if(op == 0) g << get_max(1, 1, N, a, b) << "\n";
if(op == 1) update(1, 1, N, a, b);
}
}