#include <bits/stdc++.h>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, t;
int v[400400];
int aint[400400];
void update(int nod, int poz, int val, int st, int dr)
{
if(st == dr)
{
aint[nod] = val;
return ;
}
int mijloc = (st + dr) / 2;
if(poz <= mijloc)
{
update(2 * nod, poz, val, st, mijloc);
}
else
{
update(2 * nod + 1, poz, val, mijloc + 1, dr);
}
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
}
int query(int nod, int a, int b, int st, int dr)
{
if(dr < a || st > b)
return -1;
if(st >= a && dr <= b)
{
return aint[nod];
}
int mijloc = (st + dr) / 2;
if(b <= mijloc)
{
return query(2 * nod, a, b, st, mijloc);
}
else
{
if(a >= mijloc + 1)
{
return query(2 * nod + 1, a, b, mijloc + 1, dr);
}
}
return max(query(2 * nod, a, b, st, mijloc), query(2 * nod + 1, a, b, mijloc + 1, dr));
}
int main()
{
fin >> n >> t;
for(int i = 1; i <= n; i ++)
{
fin >> v[i];
}
int pow2 = 1;
while(pow2 < n)
{
pow2 *= 2;
}
for(int i = 1; i <= n; i ++)
{
/// nod, poz, val, st, dr
update(1, i, v[i], 1, pow2);
}
while(t--)
{
int op, a, b;
fin >> op >> a >> b;
if(op == 0)
{
/// nod, a, b, st, dr
fout << query(1, a, b, 1, pow2) << '\n';
}
else
update(1,a,b,1,pow2);
}
return 0;
}