#include <bits/stdc++.h>
using namespace std;
int arb[400005],n,m;
void update(int pos, int val, int node, int st, int dr){
if (st==dr){
arb[node]=val;
return;
}
int mid=(st+dr)/2;
if (pos<=mid){
update(pos, val, 2*node, st, mid);
}
else{
update(pos, val, 2*node+1, mid+1, dr);
}
arb[node]=max(arb[node*2], arb[node*2+1]);
}
int query(int l, int r, int node, int st, int dr){
if (l<=st && dr<=r){
return arb[node];
}
int mid=(st+dr)/2;
int x=0,y=0;
if (l<=mid){
x=query(l,r,2*node, st, mid);
}
if (r>=mid+1){
y=query(l,r,2*node+1, mid+1, dr);
}
return max(x,y);
}
int main()
{
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>m;
for (int i=1;i<=n;i++){
int x;cin>>x;
update(i,x,1,1,n);
}
while (m--){
int q,a,b;cin>>q>>a>>b;
if (q==0){
cout<<query(a,b,1,1,n)<<'\n';
}
else{
update(a,b,1,1,n);
}
}
return 0;
}