#include <iostream>
#include <fstream>
#define NMax 100005
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
int N, M, ArbInt[3*NMax];
inline int Max (int a, int b)
{
if (a>b)
{
return a;
}
return b;
}
void Update (int K, int L, int R, int X, int V)
{
int Mid;
Mid=(L+R)/2;
if (L==R)
{
ArbInt[K]=V;
return;
}
if (X<=Mid)
{
Update (2*K, L, Mid, X, V);
}
else
{
Update (2*K+1, Mid+1, R, X, V);
}
ArbInt[K]=Max (ArbInt[2*K], ArbInt[2*K+1]);
}
int Query (int K, int L, int R, int QL, int QR)
{
int Mid, F1=0, F2=0;
Mid=(L+R)/2;
if ((L>=QL)&&(R<=QR))
{
return ArbInt[K];
}
if (QL<=Mid)
{
F1=Query (2*K, L, Mid, QL, QR);
}
if (QR>Mid)
{
F2=Query (2*K+1, Mid+1, R, QL, QR);
}
return Max (F1, F2);
}
int main()
{
int i, X, Tip, A, B;
fin >> N >> M;
for (i=1; i<=N; ++i)
{
fin >> X;
Update (1, 1, N, i, X);
}
for (; M>0; --M)
{
fin >> Tip >> A >> B;
if (Tip==0)
{
fout << Query (1, 1, N, A, B) << "\n";
}
else
{
Update (1, 1, N, A, B);
}
}
fin.close ();
fout.close ();
return 0;
}