#include <fstream>
#include <algorithm>
using namespace std;
int arbore[500000];
int maxim;
void update(int nod , int left, int right, int i, int val)
{
if (left == right)
{
arbore[nod] = val;
return;
}
int mijloc = (left + right) / 2;
if (i <= mijloc)
{
update(2 * nod, left, mijloc, i, val);
}
else
{
update(2 * nod + 1, mijloc + 1, right, i, val);
}
arbore[nod] = max(arbore[2 * nod], arbore[2 * nod + 1]);
}
void querry(int nod, int left, int right , int a , int b)
{
if (a <= left && right <= b)
{
if (maxim < arbore[nod])
{
maxim = arbore[nod];
}
return;
}
int mijloc = (left + right) / 2;
if (a <= mijloc)
{
querry(2 * nod, left, mijloc, a , b);
}
if (mijloc < b)
{
querry(2 * nod + 1, mijloc + 1, right, a, b);
}
}
int main()
{
ifstream in("arbint.in");
ofstream out("arbint.out");
int n , m, i , x , op , a , b;
in >> n >> m;
for (i = 1; i <= n; i++)
{
in >> x;
update(1, 1, n, i, x);
}
for (i = 0; i < m; i++)
{
in >> op >> a >> b;
if (op == 0)
{
maxim = -1;
querry(1, 1, n, a, b);
out << maxim << '\n';
}
else
{
update(1, 1, n, a, b);
}
}
in.close();
out.close();
return 0;
}