#include <iostream>
#include <string>
using namespace std;
#define NM 100000
int ARB[3*NM], N, Q, ans;
void update (int nod, int st, int dr, int pos, int nr)
{
if (st == dr)
{
ARB[nod] = nr;
return;
}
int mij = (st + dr)/2;
if (pos <= mij) update (2 * nod, st, mij, pos, nr);
else update (2 * nod + 1, mij + 1, dr, pos, nr);
ARB[nod] = max(ARB[2 * nod], ARB[2 * nod + 1]);
}
void query (int nod, int st, int dr, int a, int b)
{
if (a <= st && dr <= b)
{
ans = max (ans, ARB[nod]);
return ;
}
int mij = (st + dr)/2;
if (a <= mij) query (2 * nod, st, mij, a, b);
if (b >= mij + 1) query (2 * nod + 1, mij + 1, dr, a, b);
}
int main()
{
int pos, nr, a, b, q;
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
scanf ("%d %d", &N, &Q);
for (int i = 1; i <= N; ++i)
{
scanf ("%d", &nr);
update (1, 1, N, i, nr);
}
while (Q--)
{
scanf ("%d", &q);
if (q)
{
scanf ("%d %d", &pos, &nr);
update (1, 1, N, pos, nr);
}
else
{
scanf ("%d %d", &a, &b);
ans = 0;
query (1, 1, N, a, b);
printf ("%d\n", ans);
}
}
return 0;
}