#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
typedef unsigned long long ull;
class nod {
public:
int info;
nod* st, * dr;
};
const int sze = 1e5;
int tree[4 * sze + 1];
void buildAint(nod *&n, int st, int dr) {
n = new nod;
n->st = n->dr = nullptr;
if (st == dr) {
cin >> n->info;
return;
}
int mij = (st + dr) / 2;
buildAint(n->st, st, mij);
buildAint(n->dr, mij + 1, dr);
n->info = max(n->st->info, n->dr->info);
}
void updateAint(nod*&n, int st, int dr, int pos, int val) {
if (st == dr) {
n->info = val;
return;
}
int mij = (st + dr) / 2;
if (pos <= mij) updateAint(n->st, st, mij, pos, val);
else updateAint(n->dr, mij + 1, dr, pos, val);
n->info = max(n->st->info, n->dr->info);
}
int queryAint(nod *&n, int st, int dr, int a, int b) {
if (a <= st && dr <= b) return n->info;
int mij = (st + dr) / 2;
int s = 0, d = 0;
if (a <= mij) s = queryAint(n->st, st, mij, a, b);
if (b > mij) d = queryAint(n->dr, mij + 1, dr, a, b);
return max(s, d);
}
int main() {
int n, m;
cin >> n >> m;
nod* rad = nullptr;
buildAint(rad, 1, n);
int op, x, y;
while (m--) {
cin >> op >> x >> y;
if (op == 0) {
cout << queryAint(rad, 1, n, x, y) << "\n";
}
else {
updateAint(rad, 1, n, x, y);
}
}
return 0;
}