#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
class SegmentTree {
public:
SegmentTree(const int& length = 0) : n {length}, arb {vector<int>(4 * n + 5)}
{}
void update(int pos, int val)
{
update(1, 1, n, pos, val);
}
int query(int a, int b) const
{
int maximum = 0;
query(1, 1, n, a, b, maximum);
return maximum;
}
private:
void update(int node, int l, int r, int pos, int val)
{
if (l == r)
{
arb[node] = val;
return;
}
int mid = (l + r) / 2;
if (pos <= mid)
update(2 * node, l, mid, pos, val);
else
update(2 * node + 1, mid + 1, r, pos, val);
arb[node] = max(arb[2 * node], arb[2 * node + 1]);
}
void query(int node, int l, int r, int a, int b, int& maximum) const
{
if (a <= l && r <= b)
{
maximum = max(maximum, arb[node]);
return;
}
int mid = (l + r) / 2;
if (a <= mid)
query(2 * node, l, mid, a, b, maximum);
if (b > mid)
query(2 * node + 1, mid + 1, r, a, b, maximum);
}
int n;
vector<int> arb;
};
int n, m;
SegmentTree tree;
int main()
{
ifstream fin("arbint.in");
ofstream fout("arbint.out");
fin >> n >> m;
tree = SegmentTree(n);
int x;
for (int i = 1; i <= n; i++)
{
fin >> x;
tree.update(i, x);
}
int t, a, b;
for (int i = 0; i < m; i++)
{
fin >> t >> a >> b;
if (t)
tree.update(a, b);
else
fout << tree.query(a, b) << '\n';
}
}