#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define lsb(x) ((x) & (-x))
#define max(...) max({__VA_ARGS__})
#define min(...) min({__VA_ARGS__})
#define hmap unordered_map
#define var auto &
#define hset unordered_set
#define pq priority_queue
#define exists(x, v) (v.find(x) != v.end())
#define inrange(x, a, b) (x >= a && x <= b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef pair<ull, ull> p64_u;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef HOME
~debug() { cerr << endl; }
eni(!= ) cerr << boolalpha << i; ris;
}
eni(== ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define darr(x,n) debug() <<#x<<": "<< range(x,x+n+1)
#define dmat(x,n,m) for(int i=0;i<=n;i++) if(!i) debug() <<#x << ":" << range(x[i],x[i]+m+1); else debug() << range(x[i],x[i]+m+1);
const int lim = 1e5 + 5;
int n, m;
int a[lim];
int t[4 * lim];
void build(int idx, int l, int r)
{
if (l == r)
{
t[idx] = a[l];
return;
}
int m = (l + r) >> 1;
build(idx << 1, l, m);
build(idx << 1 | 1, m + 1, r);
t[idx] = max(t[idx << 1], t[idx << 1 | 1]);
//debug() << imie(l) imie(r) imie(t[idx]);
}
void update(int idx, int l, int r, int poz, int val)
{
if (l == r)
{
t[idx] = val;
return;
}
else
{
int m = (l + r) >> 1;
if (poz <= m)
update(idx << 1, l, m, poz, val);
else
update(idx << 1 | 1, m + 1, r, poz, val);
t[idx] = max(t[idx << 1], t[idx << 1 | 1]);
}
}
int query(int idx, int l, int r, int ql, int qr)
{
if (l > qr || r < ql)
return 0;
if (l >= ql && r <= qr)
return t[idx];
return max(query(idx << 1, l, (l + r) >> 1, ql, qr), query(idx << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr));
}
int main()
{
//#ifdef HOME
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
//endif
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i];
build(1, 1, n);
//darr(t, 4 * n);
while (m--)
{
int op, a, b;
cin >> op >> a >> b;
if (op == 1)
{
update(1, 1, n, a, b);
// darr(t, 4 * n);
}
else
{
cout << query(1, 1, n, a, b) << '\n';
}
}
return 0;
}