#include <fstream>
using namespace std;
int arbore[400005];
ifstream cin("arbint.in");
ofstream cout("arbint.out");
void update(int st, int dr, int x, int nr, int pos){
if(st == dr){
arbore[x] = nr;
}
else {
int mij = (st + dr) / 2;
if(pos <= mij){
update(st, mij, x * 2 + 1, nr, pos);
}
else {
update(mij + 1, dr, x * 2 + 2, nr, pos);
}
arbore[x] = max(arbore[x * 2 + 1], arbore[x * 2 + 2]);
}
}
int query(int st, int dr, int a, int b, int x){
if(a == st && dr == b){
return arbore[x];
}
int mij = (st + dr) / 2;
if(b <= mij){
return query(st, mij, a, b, x * 2 + 1);
}
else if(a >= mij + 1){
return query(mij + 1, dr, a, b, x * 2 + 2);
}
return max(query(st, mij, a, mij, x * 2 + 1), query(mij + 1, dr, mij + 1, b, x * 2 + 2));
}
int main()
{
int n, q;
cin >> n >> q;
for(int i = 1; i <= n; i ++){
int nr;
cin >> nr;
update(0, n - 1, 0, nr, i - 1);
}
for(int i = 1; i <= q; i ++){
int c, a, b, p, nr;
cin >> c;
if(c == 0){
cin >> a >> b;
cout << query(0, n - 1, a - 1, b - 1, 0) << "\n";
}
else {
cin >> p >> nr;
update(0, n - 1, 0, nr, p - 1);
}
}
return 0;
}