/// Problema "Arbint" - InfoArena
#include <cstdio>
#include <algorithm>
#define in "arbint.in"
#define out "arbint.out"
#define NMAX (100000 + 3)
using namespace std;
int n, m, op, a, b, v[NMAX], arb[(NMAX<<1) + NMAX];
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 update(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) update(st, mij, pos, Sfiu);
if(pos > mij) update(mij+1, dr, pos, Dfiu);
arb[nod] = max(arb[Sfiu], arb[Dfiu]);
}
int query(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 query(st, mij, st1, dr1, Sfiu);
if(st1 > mij) return query(mij+1, dr, st1, dr1, Dfiu);
return max(query(st, mij, st1, mij, Sfiu), query(mij+1, dr, mij+1, dr1, Dfiu));
}
int main()
{
freopen(in, "r", stdin);
freopen(out, "w", stdout);
scanf("%d %d", &n, &m);
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", query(1, n, a, b, 1));
if(op == 1)
{
v[a] = b;
update(1, n, a, 1);
}
}
return 0;
}