#include <fstream>
#include <vector>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n, m, x;
vector <int> v;
int arb[505];
void update(int node, int a, int b, int st, int dr){
if (st == dr){
arb[node] = b;
return;
}
int mid = (st+dr)/2;
if (a <= mid){
update(2 * node, a, b, st, mid);
}
else
update(2*node+1, a, b, mid + 1, dr);
arb[node] = max(arb[2 * node], arb[2 * node +1]);
}
int query(int node, int a, int b, int st, int dr){
if (st >= a && dr <= b){
return arb[node];
}
int mid = (st + dr) / 2;
int max1 = 0, max2 = 0;
if (a <= mid){
max1 = query(2*node, a, b, st, mid);
}
if (b > mid)
max2 = query(2*node + 1, a, b, mid + 1, dr);
return max(max1, max2);
}
int main(){
f >> n >> m;
for(int i = 1; i <= n; i ++){
f >> x;
update(1, i, x, 1, n);
}
int type, a, b;
for(int i = 0; i < m; i ++){
f >> type >> a >> b;
if (type == 0)
g << query(1, a, b, 1, n) << '\n';
else
update(1, a, b, 1, n);
}
}