hdu1754
#include<iostream>
using namespace std;
const int maxn=200000+10;
const int INF=0x3f3f3f3f;
int a[maxn],t[maxn<<2];
int N,M;
char str;
int L,R;
void pushup(int k){
t[k]=max(t[k<<1],t[k<<1|1]);
}
void build(int l,int r,int k){
if(l==r){
t[k]=a[l];
}else{
int m=((r-l)>>1)+l;
build(l,m,k<<1);
build(m+1,r,k<<1|1);
pushup(k);
}
}
void update(int p,int v,int l,int r,int k){
if(l==r){
a[p]=v;
t[k]=v;
}else{
int m=((r-l)>>1)+l;
if(p<=m)
update(p,v,l,m,k<<1);
else
update(p,v,m+1,r,k<<1|1);
pushup(k);
}
}
int query(int L,int R,int l,int r,int k){
if(L<=l&&r<=R){
return t[k];
}else{
int res=-INF;
int m=(l+r)/2;
if(L<=m){
res=max(res,query(L,R,l,m,k<<1));
}
if(R>m){
res=max(res,query(L,R,m+1,r,k<<1|1));
}
return res;
}
}
int main()
{
while(scanf("%d %d",&N,&M)!=EOF){
for(int i=1;i<=N;i++)
scanf("%d",&a[i]);
build(1,N,1);
while(M--){
getchar();
scanf("%c",&str);
scanf("%d %d",&L,&R);
if(str=='Q'){
int ans=query(L,R,1,N,1);
cout << ans << endl;
}else{
update(L,R,1,N,1);
}
}
}
return 0;
}