/// Problema "Arbint" - InfoArena
#include <cstdio>
#include <algorithm>
#define in "arbint.in"
#define out "arbint.out"
#define NMAX (100000 + 3)
using namespace std;
int m, n, v[NMAX], op, a, b, arb[(NMAX<<2)];
void init(const int &st, const int &dr, const int &nod)
{
if(st == dr)
{
arb[nod] = v[st];
return ;
}
int mij = ((st+dr)>>1), Sfiu = (nod<<1), Dfiu = ((nod<<1)|1);
init(st, mij, Sfiu);
init(mij+1, dr, Dfiu);
arb[nod] = max(arb[Sfiu], arb[Dfiu]);
}
void updateArbint(const int &st, const int &dr, const int &pos, const int &nod)
{
if(st == dr)
{
arb[nod] = v[pos];
return ;
}
int mij = ((st+dr)>>1), Sfiu = (nod<<1), Dfiu = ((nod<<1)|1);
if(pos <= mij) updateArbint(st, mij, pos, Sfiu);
if(pos > mij) updateArbint(mij+1, dr, pos, Dfiu);
arb[nod] = max(arb[Sfiu], arb[Dfiu]);
}
int queryArbint(const int &st, const int &dr, const int &st1, const int &dr1, const int &nod)
{
if(st == st1 && dr == dr1)
{
return arb[nod];
}
int mij = ((st+dr)>>1), Sfiu = (nod<<1), Dfiu = ((nod<<1)|1);
if(dr1 <= mij) return queryArbint(st, mij, st1, dr1, Sfiu);
if(st1 > mij) return queryArbint(mij+1, dr, st1, dr1, Dfiu);
return max(queryArbint(st, mij, st1, mij, Sfiu), queryArbint(mij+1, dr, mij+1, dr1, Dfiu));
}
inline void citire()
{
scanf("%d %d", &m, &n);
for(int i = 1; i<= n; ++i) scanf("%d", &v[i]);
init(1, n, 1);
for( ; m; --m)
{
scanf("%d %d %d", &op, &a, &b);
if(op == 0)
{
printf("%d\n", queryArbint(1, n, a, b, 1));
}
if(op == 1)
{
v[a] = b;
updateArbint(1, n, a, 1);
}
}
}
int main()
{
freopen(in, "r", stdin);
freopen(out, "w", stdout);
citire();
return 0;
}