#include <algorithm>
#include <iostream>
#include <fstream>
int N, M;
//-----------------------------------------------------------------------------
template<int MaxElements>
struct ArbInt {
int A[MaxElements];
ArbInt() {
for (int i = 0; i < MaxElements; i++)
this->A[i] = 0;
}
inline void update(const int &Node, const int &Left, const int &Right, const int &Value, const int &Position) {
if (Left == Right) {
this->A[Node] = Value;
return ;
}
const int &Middle = Left + (Right - Left) / 2;
if (Position <= Middle)
update(Node * 2, Left, Middle, Value, Position);
else
update(Node * 2 + 1, Middle + 1, Right, Value, Position);
this->A[Node] = std::max(this->A[Node * 2], this->A[Node * 2 + 1]);
}
inline int query(const int &Node, const int &Left, const int &Right, const int &iLeft, const int &iRight) {
if (iLeft <= Left && Right <= iRight) {
return this->A[Node];
}
const int &Middle = Left + (Right - Left) / 2; int Result = 0;
if (iLeft <= Middle)
Result = std::max(Result, query(Node * 2, Left, Middle, iLeft, iRight));
if (Middle < iRight)
Result = std::max(Result, query(Node * 2 + 1, Middle + 1, Right, iLeft, iRight));
return Result;
}
};
//-----------------------------------------------------------------------------
ArbInt<300100> AI;
void Make() {
std::ifstream fin("arbint.in");
fin >> N >> M;
for (register int i = 1; i <= N; i++) {
int aux;
fin >> aux;
AI.update(1, 1, N, aux, i);
}
std::ofstream fout("arbint.out");
for (register int i = 1; i <= M; i++) {
int Operation;
fin >> Operation;
if (Operation == 0) {
int Left, Right;
fin >> Left >> Right;
fout << AI.query(1, 1, N, Left, Right) << '\n';
} else {
int Value, Position;
fin >> Position >> Value;
AI.update(1, 1, N, Value, Position);
}
}
}
int main() {
Make();
}