#include <fstream>
#include <vector>
#define INF 1e9+1
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int v[200005];
int n,q;
struct arbore {
vector<long long> tree;
void init () {
tree.assign(4*n+4,-INF);
}
void build (int node, int l, int r) {
if (l==r) {
tree[node]=v[l];
return;
}
int mid=(l+r)/2;
build(node*2,l,mid);
build(node*2+1,mid+1,r);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
void pointUpdate(int node, int l, int r, int pos, long long val) {
if (l==r) {
tree[node]=val;
return;
}
int mid=(l+r)/2;
if (pos<=mid) pointUpdate(node*2,l,mid,pos,val);
else pointUpdate(node*2+1,mid+1,r,pos,val);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
long long rangeQuery(int node, int l, int r, int ql, int qr) {
if (qr<l || r<ql) {
return -INF;
}
if (ql<=l && r<=qr) {
return tree[node];
}
int mid=(l+r)/2;
return max(rangeQuery(node*2,l,mid,ql,qr),rangeQuery(node*2+1,mid+1,r,ql,qr));
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>q;
for (int i=1; i<=n; ++i) cin>>v[i];
arbore st;
st.init();
st.build(1,1,n);
while (q--) {
int type;
cin>>type;
if (type==1) {
int pos;
long long x;
cin>>pos>>x;
st.pointUpdate(1,1,n,pos,x);
}
else if (type==0) {
int l, r;
cin>>l>>r;
cout<<st.rangeQuery(1,1,n,l,r)<<'\n';
}
}
}