#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("arbint.in");
ofstream out ("arbint.out");
int AINT[1 << 18];
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);
}
int main()
{
int N, Q, i, tip, x, y;
in >> N >> Q;
for (i = 1; i <= N; i ++){
in >> x;
update (1, 1, N, i, x);
}
while (Q --){
in >> tip >> x >> y;
if (tip)
update (1, 1, N, x, y);
else
out << query (1, 1, N, x, y) << "\n";
}
return 0;
}