#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n, m;
int arb[4 * 100000 + 5];
void add(const int& node, const int& left, const int& right, const int& poz, const int& val) {
if(left > right || poz < left || right < poz) {
return;
}
if(left == right) {
arb[node] = val;
return;
}
int mid = (left + right) >> 1;
add(2 * node, left, mid, poz, val);
add(2 * node + 1, mid + 1, right, poz, val);
arb[node] = max(arb[2 * node], arb[2 * node + 1]);
}
int query(const int& node, const int& st, const int& dr, const int& a, const int& b) {
if(st > dr || st > b || dr < a) {
return 0;
}
if(a <= st && dr <= b) {
return arb[node];
}
int m = (st + dr) >> 1;
return max(query(2 * node, st, m, a, b), query(2 * node + 1, m + 1, dr, a, b));
}
void read() {
f>>n>>m;
int x;
for(int i = 1;i <= n;++i) {
f>>x;
add(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';
continue;
}
add(1, 1, n, y, z);
}
f.close();
g.close();
}
int main() {
read();
solve();
return 0;
}