#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("arbint.in");
ofstream out ("arbint.out");
int AINT[1 << 18];
inline int max2 (const int &A, const int &B)
{
if (A > B)
return A;
return B;
}
void update (const int &nod, const int &st, const int &dr, const int &poz, const int &val)
{
if (st == dr){
AINT[nod] = val;
return;
}
int mid = (st + dr) / 2;
if (poz <= mid)
update (nod * 2, st, mid, poz, val);
else
update (nod * 2 + 1, mid + 1, dr, poz, val);
AINT[nod] = max (AINT[nod * 2], AINT[nod * 2 + 1]);
}
int query (const int &nod, const int &st, const int &dr, const int &a, const int &b)
{
if (st == dr)
return AINT[nod];
int mid = (st + dr) / 2;
int mx1 = 0, mx2 = 0;
if (a <= mid)
mx1 = query (nod * 2, st, mid, a, b);
if (mid < b)
mx2 = query (nod * 2 + 1, mid + 1, dr, a, b);
return max2 (mx1, mx2);
}
int main()
{
int N, M, i, op, a, b;
in >> N >> M;
for (i = 1; i <= N; i ++){
in >> a;
update (1, 1, N, i, a);
}
for (i = 1; i <= M; i ++){
in >> op >> a >> b;
if (op == 0)
out << query (1, 1, N, a, b) << "\n";
else
update (1, 1, N, a, b);
}
return 0;
}