#include "bits/stdc++.h"
#include <type_traits>
using namespace std;
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
// ============ Macros starts here ============
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif // DEBUG
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(Ostream& os, const Cont& v) {
os << "[";
for (auto& x : v) { os << x << ", "; }
return os << "]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
return os << "{" << p.first << ", " << p.second << "}";
}
#define readFast \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#ifdef LOCAL
#define read() ifstream fin("date.in.txt")
#else
#define read() readFast
#endif // LOCAL
// ============ Macros ends here ============
// --
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//--
#define fin cin
#define ll long long
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define output(x) (((int)(x) && cout << "YES\n") || cout << "NO\n")
#define LSB(x) (x & (-x))
#define test cout << "WORKS\n";
const int N = 3e5 + 15;
const int MOD = 998244353;
int t;
struct SegTree {
vector<int> arr;
int size;
int e_neutru;
SegTree(int n, int neutru = 0) {
e_neutru = neutru;
arr.assign(4 * n, e_neutru);
size = n;
};
void debug_print() {
int p = 1, i = 1;
while (i < sz(arr)) {
int end = i + p;
while (i < end) {
if (i < sz(arr))
cout << arr[i] << " ";
else
cout << 0 << " ";
++i;
}
cout << '\n';
i = end;
p *= 2;
}
cout << '\n';
}
int op(int a, int b) {
return max(a, b);
}
void update(int pos, int val) {
update(1, 1, size, pos, val);
// debug_print();
}
void update(int nod, int st, int dr, int pos, int val) {
// cout << "nod=" << nod << " st=" << st << " dr=" << dr << " pos=" << pos << '\n';
if (pos == st && pos == dr) {
arr[nod] = val;
return;
}
int mid = (st + dr) / 2;
if (pos <= mid) {
update(nod * 2, st, mid, pos, val);
} else if (pos > mid) {
update(nod * 2 + 1, mid + 1, dr, pos, val);
}
arr[nod] = op(arr[nod * 2], arr[nod * 2 + 1]);
}
int query(int l, int r) {
return query(1, 1, size, l, r);
}
int query(int nod, int st, int dr, int a, int b) {
// cout << "nod=" << nod << " st=" << st << " dr=" << dr << '\n';
if (a <= st && dr <= b) {
return arr[nod];
}
int mid = (st + dr) / 2, res_left = e_neutru, res_right = e_neutru;
if (a <= mid) {
res_left = query(nod * 2, st, mid, a, b);
}
if (b > mid) {
res_right = query(nod * 2 + 1, mid + 1, dr, a, b);
}
return op(res_left, res_right);
}
};
int main() {
// read();
ifstream fin("arbint.in");
ofstream cout("arbint.out");
int n, m;
fin >> n >> m;
SegTree segTree(n);
for (int i = 1; i <= n; ++i) {
int val;
fin >> val;
segTree.update(i, val);
}
while (m--) {
int t, a, b;
fin >> t >> a >> b;
if (t == 1) {
segTree.update(a, b);
} else {
cout << segTree.query(a, b) << '\n';
}
}
return 0;
} /*stuff you should look for !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* test the solution with the given example
* int overflow, array bounds, matrix bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
~Benq~*/