#include <fstream>
#define input "arbint.in"
#define output "arbint.out"
#define NMAX 100005
using namespace std;
ifstream in(input);
ofstream out(output);
int arb[4*NMAX + 100], N, M;
void Update(int nod, int st, int dr, int val, int poz)
{
if(st == dr)
{
arb[nod] = val;
return;
}
int midd = (st + dr) / 2;
if(poz <= midd) Update(2 * nod, st, midd, val, poz);
else Update(2* nod + 1, midd + 1, dr, val, poz);
arb[nod] = max(arb[2 * nod], arb[2 * nod + 1]);
}
int Max_Interv(int nod, int st, int dr, int A, int B)
{
if(A <= st && dr <= B) return arb[nod];
int midd = (st + dr) / 2, a = 0, b = 0;
if(A <= midd) a = Max_Interv(2 * nod, st, midd, A, B);
if(midd < B) b = Max_Interv(2 * nod + 1, midd + 1, dr, A, B);
return max(a, b);
}
void Read_Data()
{
in >> N >> M;
for(int i = 1; i <= N; i++)
{
int x; in >> x;
Update(1, 1, N, x, i);
}
for(int i = 1; i <= M; i++)
{
int task, A, B; in >> task >> A >> B;
if(task == 0) out << Max_Interv(1, 1, N, A, B) << "\n";
else Update(1, 1, N, B, A);
}
}
int main()
{
Read_Data();
return 0;
}