#include <iostream>
#include <fstream>
#include <deque>
using namespace std;
ifstream fin("aint.in");
ofstream fout("aint.out");
int t[400005], n, mx;
void update(int v, int tl, int tr, int pos, int new_val)
{
if (tl == tr)
{
t[v] = new_val;
return;
}
int tm = (tl + tr) / 2;
if (pos <= tm)
update(v * 2, tl, tm, pos, new_val);
else
update(v * 2 + 1, tm + 1, tr, pos, new_val);
t[v] = max(t[v * 2], t[v * 2 + 1]);
}
void Query(int nod, int left, int right, int start, int finish)
{
if (start <= left && right <= finish)
{
if (mx < t[nod]) mx = t[nod];
return;
}
int div = (left + right) / 2;
if (start <= div) Query(2 * nod, left, div, start, finish);
if (div < finish) Query(2 * nod + 1, div + 1, right, start, finish);
}
int main()
{
int i, q, op, x, y;
fin >> n >> q;
for (i = 1; i <= n; i++)
{
fin >> x;
update(1, 1, n, i, x);
}
while (q--)
{
fin >> op >> x >> y;
if (op == 1)
update(1, 1, n, x, y);
else
{
mx = -1;
Query(1, 1, n, x, y);
fout << mx << "\n";
}
}
return 0;
}