#include <bits/stdc++.h>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
#define N_MAX 100003
int N, M, val, a, b, poz;
int Arbore [4 * N_MAX];
void Update (int nod, int st, int dr, int poz, int val){
if (st == dr){
Arbore [nod] = val;
return;
}
else{
int med = (st + dr) / 2;
if (poz <= med)
Update (2 * nod, st, med, poz, val);
else
Update ((2 * nod) + 1, med + 1, dr, poz, val);
Arbore [nod] = max (Arbore [2 * nod], Arbore [(2 * nod) + 1]);
}
}
int Query (int nod, int st, int dr, int qdr, int qst){
if (dr < qdr || st > qst)
return 0;
if (qdr <= st && dr <= qst)
return Arbore [nod];
else{
int med = (st + dr) / 2;
int q1 = Query (2 * nod, st, med, qdr, qst);
int q2 = Query ((2 * nod) + 1, med + 1, dr, qdr, qst);
return max (q1, q2);
}
}
int main(){
fin >> N >> M;
for(int i = 1; i <= N; i++){
fin >> val;
Update (1, 1, N, i, val);
}
for(int i = 1, type; i <= M; i++){
fin >> type;
if (type != 0){
fin >> poz >> val;
Update (1, 1, N, poz, val);
}
else{
fin >> a >> b;
fout << Query (1, 1, N, a, b) << '\n';
}
}
return 0;
}