#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int NMAX = 50007;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int Arbi[NMAX * 4];
int n, m;
int ans;
void update(int node, int st, int dr, int poz, int val) {
if(st == dr) {
Arbi[node] = val;
return;
}
int med = (st + dr) >> 1;
if(med >= poz) {
update(node * 2, st, med, poz, val);
}
else {
update(node * 2 + 1, med + 1, dr, poz, val);
}
Arbi[node] = max(Arbi[node * 2], Arbi[node * 2 + 1]);
}
void query(int node, int st, int dr, int x, int y) {
if(st >= x && dr <= y) {
ans = max(ans, Arbi[node]);
return;
}
int med = (st + dr) >> 1;
if(med >= x) {
query(node * 2, st, med, x, y);
}
if(med < y) {
query(node * 2 + 1, med + 1, dr, x, y);
}
}
int main() {
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
int x;
cin >> x;
update(1, 1, n, i, x);
}
for(int i = 1; i <= m; ++i) {
int type, a, b;
cin >> type >> a >> b;
if(type == 1) {
update(1, 1, n, a, b);
}
else {
ans = 0;
query(1, 1, n, a ,b);
cout << ans << "\n";
}
}
return 0;
}