#include <bits/stdc++.h>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m, a[100001], st[400001], i, c, aa, b;
void build(int a[], int x, int tl, int tr){
if(tl == tr)
st[x] = a[tl];
else{
int tm = (tl + tr) / 2;
build(a, x * 2, tl, tm);
build(a, x * 2 + 1, tm + 1, tr);
st[x] = max(st[x * 2], st[x * 2 + 1]);
}
}
int maxi(int x, int tl, int tr, int l, int r){
if(l > r)
return 0;
if(l == tl && r == tr)
return st[x];
int tm = (tl + tr) / 2;
return max(maxi(x * 2, tl, tm, l, min(r, tm)), maxi(x * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int x, int tl, int tr, int pos, int new_val){
if(tl == tr)
st[x] = new_val;
else{
int tm = (tl + tr) / 2;
if(pos <= tm)
update(x * 2, tl, tm, pos, new_val);
else
update(x * 2 + 1, tm + 1, tr, pos, new_val);
st[x] = max(st[x * 2], st[x * 2 + 1]);
}
}
int main(){
fin >> n >> m;
for(i = 1; i <= n; i++)
fin >> a[i];
build(a, 1, 1, n);
for(i = 1; i <= m; i++){
fin >> c >> aa >> b;
if(c == 0)
fout << maxi(1, 1, n, aa, b) << '\n';
else
update(1, 1, n, aa, b);
}
}