#include <bits/stdc++.h>
#define NMAX 100005
using namespace std;
int arb[4*NMAX + 55], maxx;
void update(int nod, int st, int dr, int poz, int val){
if(st == dr){
arb[nod] = val;
return;
}
int mid = (st + dr) / 2;
if(poz <= mid) update(2*nod, st, mid, poz, val);
else if(poz > mid) update(2*nod+1, mid+1, dr, poz, val);
arb[nod] = max(arb[2*nod], arb[2*nod+1]);
}
void query(int nod, int st, int dr, int x, int y){
if(x <= st && dr <= y){
maxx = max(maxx, arb[nod]);
return;
}
int mid = (st + dr) / 2;
if(x <= mid) query(2*nod, st, mid, x, y);
if(y > mid) query(2*nod+1, mid+1, dr, x, y);
}
int main(){
ifstream in("arbint.in");
ofstream out("arbint.out");
int n, q, a, t, x, y;
in >> n >> q;
for(int i = 1; i <= n; i++){
in >> a;
update(1, 1, n, i, a);
}
for(int i = 1; i <= q; i++){
in >> t >> x >> y;
if(t == 1){
update(1, 1, n, x, y);
}
else{
maxx = 0;
query(1, 1, n, x, y);
out << maxx << endl;
}
}
}