#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
using namespace std;
#define oo 0x3f3f3f3f
ifstream f("arbint.in");
ofstream g("arbint.out");
int n, m;
int arb[4 * 100000 + 1];
void update(const int& node, const int& left, const int& right, const int& position, const int& value) {
if(left > right || left > position || position > right) {
return;
}
if(left == right) {
arb[node] = value;
return;
}
int mid = (left + right) >> 1;
update(2 * node, left, mid, position, value);
update(2 * node + 1, mid + 1, right, position, value);
arb[node] = max(arb[2 * node], arb[2 * node + 1]);
}
int query(const int& node, const int& left, const int& right, const int& a, const int& b) {
if(left > right || a > right || b < left) {
return 0;
}
if(a <= left && b >= right) {
return arb[node];
}
int mid = (left + right) >> 1;
return max(query(2 * node, left, mid, a, b), query(2 * node + 1, mid + 1, right, a, b));
}
void read() {
f>>n>>m;
int x;
for(int i = 1;i <= n;++i) {
f>>x;
update(1, 1, n, i, x);
}
}
void solve() {
int x, y, z;
for(int i = 1;i <= m;++i) {
f>>x>>y>>z;
if(!x) {
g<<query(1, 1, n, y, z)<<'\n';
} else {
update(1, 1, n, y, z);
}
}
}
int main() {
read();
solve();
return 0;
}