#include <cstdio>
#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()
{
FILE *in = fopen("arbint.in", "r");
FILE *out = fopen("arbint.out", "w");
int n , m, i , x , op , a , b;
fscanf(in , "%d%d", &n, &m);
for (i = 1; i <= n; i++)
{
fscanf(in, "%d", &x);
update(1, 1, n, i, x);
}
for (i = 0; i < m; i++)
{
fscanf(in, "%d%d%d", &op, &a, &b);
if (op == 0)
{
maxim = -1;
querry(1, 1, n, a, b);
fprintf(out, "%d\n", maxim);
}
else
{
update(1, 1, n, a, b);
}
}
fclose(in);
fclose(out);
return 0;
}