#include <cstdio>
using namespace std;
int AINT[1 << 18];
char *Buffer;
inline int max (const int &A, const int &B)
{
if (A > B)
return A;
return B;
}
void update (int nod, int st, int dr, int poz, int val)
{
if (st == dr){
AINT[nod] = val;
return;
}
int mid = (st + dr) >> 1;
if (poz <= mid)
update (nod << 1, st, mid, poz, val);
else
update (nod << 1 | 1, mid + 1, dr, poz, val);
AINT[nod] = max (AINT[nod << 1], AINT[nod << 1 | 1]);
}
int query (int nod, int st, int dr, int a, int b)
{
if (a <= st && dr <= b)
return AINT[nod];
int mid = (st + dr) >> 1;
int aux1 = 0, aux2 = 0;
if (a <= mid)
aux1 = query (nod << 1, st, mid, a, b);
if (mid < b)
aux2 = query (nod << 1 | 1, mid + 1, dr, a, b);
return max (aux1, aux2);
}
inline void read (int &X)
{
X &= 0;
while (*Buffer < '0' || *Buffer > '9')
++ Buffer;
while (*Buffer >= '0' && *Buffer <= '9')
X = (X * 10) + (*(Buffer ++) - '0');
}
int main()
{
int N, Q, i, tip, x, y;
long long fs;
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
fseek (stdin, 0, SEEK_END);
fs = ftell (stdin);
Buffer = new char [fs];
rewind (stdin);
fread (Buffer, 1, fs, stdin);
read (N), read (Q);
for (i = 1; i <= N; i ++){
read (x);
update (1, 1, N, i, x);
}
while (Q --){
read (tip), read (x), read (y);
if (tip)
update (1, 1, N, x, y);
else
printf ("%d\n", query (1, 1, N, x, y));
}
return 0;
}