#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int NMAX = 1e5 + 5;
vector <int> aint(NMAX * 4), v(NMAX);
int n, m;
void build(int nod, int st, int dr) {
if (st == dr) {
aint[nod] = v[st];
return ;
}
int mij = (st + dr) >> 1;
build(2 * nod, st, mij);
build(2 * nod + 1, mij + 1, dr);
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
}
void update(int nod, int st, int dr, int pos, int val) {
if (st == dr) {
aint[nod] = val;
return;
}
int mij = (st + dr) >> 1;
if (pos <= mij) update(2 * nod, st, mij, pos, val);
else update(2 * nod + 1, mij + 1, dr, pos, val);
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
}
int query(int nod, int st, int dr, int x, int y){
if(dr < x || st > y)
return 0;
if(x <= st && dr <= y)
return aint[nod];
int mij=(st + dr) / 2;
return max(query(nod * 2, st, mij, x, y), query(nod * 2 + 1, mij+1, dr, x, y));
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; ++i) fin >> v[i];
build(1, 1, n);
for (int i = 1, op, x, y; i <= m; ++i) {
fin >> op >> x >> y;
if (op == 0) fout << query(1, 1, n, x, y) << '\n';
else update(1, 1, n, x, y);
}
return 0;
}