#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
struct query
{
int f, s;
};
int n, m, x;
int a[400003];
void upd(int nod, int l,int r, query q)
{
if (l == r)
{
a[nod] = q.s;
return;
}
int mid = (l + r) / 2;
if (q.f <= mid)
upd(2 * nod, l, mid, q);
else
upd(2 * nod + 1, mid+1, r, q);
a[nod] = max(a[2 * nod],a[2 * nod + 1]);
}
int que(int nod, int l, int r, query q)
{
if (q.f <= l && q.s >= r)
return a[nod];
int mid = (l + r) / 2, s1 = 0, s2 = 0;
if (mid >= q.f)
s1 = que(2 * nod, l, mid, q);
if (mid + 1 <= q.s)
s2 = que(2 * nod + 1, mid + 1, r, q);
return max(s1,s2);
}
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
cin >> x;
upd(1, 1, n, { i,x });
}
int c, x, y;
for (int i = 1; i <= m; i++)
{
cin >> c >> x >> y;
if (c == 0)
cout << que(1, 1, n, { x,y }) << '\n';
else upd(1, 1, n, { x,y });
}
return 0;
}