#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int NMax = 100000;
int N,M,Max;
int A[NMax + 5],AINT[4*NMax];
void Read()
{
fin >> N >> M;;
for(int i = 1; i <= N; ++i)
fin >> A[i];
}
void Update(int i, int Left, int Right,int a, int b)
{
if(Left == Right)
{
AINT[i] = b;
return;
}
int Mid = (Left + Right)/2;
if(a <= Mid)
Update(2*i,Left,Mid,a,b);
else
Update(2*i+1,Mid+1,Right,a,b);
AINT[i] = max(AINT[2*i],AINT[2*i+1]);
}
void Build()
{
for(int i = 1; i <= N; ++i)
Update(1,1,N,i,A[i]);
}
void Query(int i, int Left, int Right, int a, int b)
{
if(a <= Left && Right <= b)
{
Max = max(Max,AINT[i]);
return;
}
if(a > Right || b < Left)
return;
int Mid = (Left+Right)/2;
Query(2*i,Left,Mid,a,b);
Query(2*i+1,Mid+1,Right,a,b);
}
void Solve()
{
while(M--)
{
int op,a,b;
fin >> op >> a >> b;
if(op == 1)
Update(1,1,N,a,b);
if(op == 0)
{
Max = 0;
Query(1,1,N,a,b);
fout << Max << "\n";
}
}
}
int main()
{
Read();
Build();
Solve();
return 0;
}