// https://goo.gl/fBmFxu
#include <bits/stdc++.h>
using namespace std;
#define NMAX 100009
#define MMAX 200009
#define kInf (1 << 30)
#define kInfLL (1LL << 60)
#define kMod 666013
#define edge pair<int, int>
#define x first
#define y second
#define USE_FILES "MLC"
#ifdef USE_FILES
#define cin fin
#define cout fout
ifstream fin("arbint.in");
ofstream fout("arbint.out");
#endif
// number of tests from "in"
int test_cnt = 1;
void clean_test();
// your global variables are here
// Binary Indexed Trees
template<typename T = int>
struct AINT {
// UPDATE UPDATE i
// MIN MIN[i, j]
// MAX MAX[i, j]
int size;
vector<T> aint; // aint[0], aint[1], ..., aint[size]
T default_value;
T& (*func)(T&, T&);
AINT(int _size, T& (*_func)(T&, T&), T _default_value) :
size(_size),
aint(4 * _size + 1, 0),
func(_func),
default_value(_default_value) {
}
void update(int pos, T val) {
helper_update(1, 1, size, pos, pos, val);
}
void helper_update(int node, int left, int right, int a, int b, T &val) {
if (left == right) {
aint[node] = val;
return;
}
int middle = (left + right) / 2;
int lson = 2 * node, rson = 2 * node + 1;
if (a <= middle) helper_update(lson, left, middle, a, b, val);
else helper_update(rson, middle + 1, right, a, b, val);
aint[node] = func(aint[lson], aint[rson]);
}
T query(int a, int b) {
return helper_query(1, 1, size, a, b);
}
T helper_query(int node, int left, int right, int a, int b) {
if (a <= left && right <= b) {
return aint[node];
}
int middle = (left + right) / 2;
int lson = 2 * node, rson = 2 * node + 1;
int lsol = default_value, rsol = default_value;
if (a <= middle) lsol = helper_query(lson, left, middle, a, b);
if (middle < b) rsol = helper_query(rson, middle + 1, right, a, b);
return func(lsol, rsol);
}
};
int& func_min(int &a, int &b) {
return a <= b ? a : b;
}
int& func_max(int &a, int &b) {
return a >= b ? a : b;
}
// your solution is here
void solve() {
int n, Q;
cin >> n >> Q;
// AINT<int> aint(n + 1, func_min, numeric_limits<int>::max());
AINT<int> aint(n + 1, func_max, numeric_limits<int>::min());
vector<int> v(n + 1);
for (int i = 1; i <= n; ++i) {
int x;
cin >> x;
aint.update(i, x);
}
while (Q--) {
int type, start, end, x, pos;
cin >> type;
switch (type) {
case 0: {
cin >> start >> end;
cout << aint.query(start, end) << "\n";
break;
}
case 1: {
cin >> pos >> x;
aint.update(pos, x);
v[pos] = x;
break;
}
default: {
cout << "wtf?";
break;
}
}
}
if (test_cnt > 0) {
clean_test();
}
}
void clean_test() {
// clean if needed
}
int main() {
// cin >> test_cnt;
while (test_cnt--) {
solve();
}
return 0;
}