#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int NMAX = 100005;
int a[NMAX * 4], v[NMAX];
void build(int nod, int st, int dr)
{
if (st == dr)
{
a[nod] = v[st];
return;
}
int mij = (st + dr) / 2;
build(2 * nod, st, mij);
build(2 * nod + 1, mij + 1, dr);
a[nod] = max(a[2 * nod], a[2 * nod + 1]);
}
void update(int nod, int st, int dr, int pos, int val)
{
if (pos < st || pos > dr) return;
if (st == dr)
{
a[nod] = val;
return;
}
int mij = (st + dr) / 2;
update(2 * nod, st, mij, pos, val);
update(2 * nod + 1, mij + 1, dr, pos, val);
a[nod] = max(a[2 * nod], a[2 * nod + 1]);
}
int query(int nod, int st, int dr, int x, int y)
{
if (y < st || x > dr) return 0;
if (st == dr)
return a[nod];
int mij = (st + dr) / 2;
return max(query(2 * nod, st, mij, x, y), query(2 * nod + 1, mij + 1, dr, x, y));
}
int n, q;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(0); fout.tie(0);
fin >> n >> q;
for (int i = 1; i <= n; i++)
fin >> v[i];
build(1, 1, n);
while (q--)
{
int tip;
fin >> tip;
if (tip == 1)
{
int a, b;
fin >> a >> b;
update(1, 1, n, a, b);
}
else
{
int a, b;
fin >> a >> b;
fout << query(1, 1, n, a, b) << '\n';
}
}
return 0;
}