#include <fstream>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
#define DIM 100001
int arbore[DIM * 4], n, m, i, x, tip, y;
static inline void update(int a, int b, int nod, int poz, int val) {
if(a == b)
arbore[nod] = val;
else {
int mid = (a + b) / 2;
if(poz <= mid)
update(a, mid, nod * 2, poz, val);
else update(mid + 1, b, nod * 2 + 1, poz, val);
arbore[nod] = max(arbore[nod * 2], arbore[nod * 2 + 1]); ///maximul pe fiecare interval
}
}
static inline int query(int a, int b, int nod, int st, int dr) {
int max1 = 0, max2 = 0;
if(st <= a && b <= dr)
return arbore[nod];
int mid = (a + b) / 2;
if(st <= mid)
max1 = query(a, mid, nod * 2, st, dr);
if(mid < dr)
max2 = query(mid + 1, b, nod * 2 + 1, st, dr);
return max(max1, max2);
}
int main() {
cin >> n >> m;
for(i = 1; i <= n; i++) {
cin >> x;
update(1, n, 1, i, x);
}
for(i = 1; i <= m; i++) {
cin >> tip >> x >> y;
if(tip == 0)
cout << query(1, n, 1, x, y) << '\n';
else update(1, n, 1, x, y);
}
return 0;
}