#include <fstream>
#include <cstring>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
const int NMAX = 100009;
int N; int A[NMAX * 4]; int M; int V[NMAX]; int max_value;
void build(int nod, int st, int dr) {
if(st == dr) {A[nod] = V[st]; return ;}
int mid = (st + dr) / 2;
build(nod * 2, st, mid);
build(nod * 2 + 1, mid + 1, dr);
A[nod] = max(A[nod * 2], A[nod * 2 + 1]);
}
void update(int nod, int st, int dr, const int& pos, const int& value) {
if(st == dr) {A[nod] = value; return;}
int mid = (st + dr) / 2;
if(pos <= mid)
update(nod * 2, st, mid, pos, value);
else update(nod * 2 + 1, mid + 1, dr, pos, value);
A[nod] = max(A[nod * 2 + 1], A[nod * 2]);
}
void query(int nod, int st, int dr, const int& pos_st, const int& pos_dr) {
if(pos_st <= st && dr <= pos_dr) {
max_value = max(max_value, A[nod]);
return ;
}
int mid = (st + dr) / 2;
if(pos_st <= mid) query(nod * 2, st, mid, pos_st, pos_dr);
if(mid < pos_dr) query(nod * 2 + 1, mid + 1, dr, pos_st, pos_dr);
}
int main() {
fin >> N >> M;
for(int i = 1; i <= N; ++i)
fin >> V[i];
build(1, 1, N);
for(int i = 1; i <= M; ++i) {
int type, a, b;
fin >> type >> a >> b;
if(type == 1) update(1, 1, N, a, b);
if(type == 0) {
max_value = 0;
query(1, 1, N, a, b);
fout << max_value << '\n';
}
}
return 0;
}