#include <bits/stdc++.h>
using namespace std;
int aint[400005];
int v[100005];
int qlf, qrg, val;
int combine(const int &a, const int &b){
if(a > b){
return a;
}
return b;
}
void build(const int &pos, const int &lf, const int &rg){
if(lf == rg){
aint[pos] = v[lf];
return;
}
int md = (lf + rg)/2;
build(2 * pos, lf, md);
build(2 * pos + 1, md + 1, rg);
aint[pos] = combine(aint[2 * pos], aint[2 * pos + 1]);
}
int query(const int &pos, const int &lf, const int &rg){
if(lf > qrg || rg < qlf){
return -1;
}else if(qlf <= lf && rg <= qrg){
return aint[pos];
}
int md = (lf + rg)/2;
return combine(query(2 * pos, lf, md), query(2 * pos + 1, md + 1, rg));
}
int update(const int &pos, const int &lf, const int &rg){
if(lf == rg && lf == qlf){
aint[pos] = val;
return aint[pos];
}else if(lf <= qlf && qlf <= rg){
int md = (lf + rg)/2;
aint[pos] = combine(update(2 * pos, lf, md), update(2 * pos + 1, md + 1, rg));
}
return aint[pos];
}
int main()
{
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
int n,q,i;
scanf("%d %d", &n, &q);
for(i = 1;i <= n;i++){
scanf("%d", &v[i]);
}
build(1, 1, n);
for(i = 1;i <= q;i++){
int op, x, y;
scanf("%d %d %d", &op, &x, &y);
if(op == 0){
qlf = x;
qrg = y;
printf("%d\n", query(1, 1, n));
}else{
qlf = x;
val = y;
update(1, 1, n);
}
}
return 0;
}