#include <bits/stdc++.h>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
int pom[400005],v[100005],ans;
void build (int nod, int st, int dr)
{
if (st == dr)
pom[nod] = v[st];
else
{
int md = (st + dr) / 2;
build(2 * nod, st, md);
build(2 * nod + 1, md + 1, dr);
pom[nod] = max(pom[2 * nod], pom[2 * nod + 1]);
}
}
void update (int nod, int st, int dr, int pos, int val) {
if (st == dr)
pom[nod] = val;
else
{
int md = (st + dr) / 2;
if (pos <= md)
update(2 * nod, st, md, pos, val);
if (pos >= md + 1)
update (2 * nod + 1, md + 1, dr, pos, val);
pom[nod] = max(pom[2 * nod], pom[2 * nod + 1]);
}
}
void query (int nod, int st, int dr, int a, int b) {
if (a <= st && dr <= b)
ans = max(ans, pom[nod]);
else
{
int mid = (st + dr) / 2;
if (a <= mid)
query(2 * nod, st, mid, a, b);
if (b >= mid + 1)
query(2 * nod + 1, mid + 1, dr, a, b);
}
}
int ok,n,m,a,b;
int main()
{
fin >> n >> m;
for (int i = 1;i <= n;i++)
fin >> v[i];
build(1, 1, n);
for (int i = 1; i <= m; i++)
{
fin >> ok >> a >> b;
if (ok == 0)
{
ans = 0;
query(1, 1, n, a, b);
fout << ans << '\n';
}
if (ok == 1)
update(1, 1, n, a, b);
}
return 0;
}