hdu1754
#include<stdio.h>
#include<iostream>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int Maxn=200000+5;
int ma[Maxn*4];
int max(int i,int j){
return i>j?i:j;
}
void pushup(int rt){
ma[rt]=max(ma[rt<<1],ma[rt<<1|1]);
}
void build(int l,int r,int rt){
if(l==r){
scanf("%d",&ma[rt]);
return;
}
int m=(l+r)>>1;
build(lson);
build(rson);
pushup(rt);
}
void update(int p,int v,int l,int r,int rt){
if(l==r){
ma[rt]=v;
return;
}
int m=(l+r)>>1;
if(p<=m)update(p,v,lson);
else update(p,v,rson);
pushup(rt);
}
int query(int x,int y,int l,int r,int rt){
if(x<=l&&y>=r){
return ma[rt];
}
int m=(l+r)>>1;
int res=0;
if(x<=m)res=max(res,query(x,y,lson));
if(y>m)res=max(res,query(x,y,rson));
return res;
}
int main(){
int n,m;
while(~scanf("%d%d",&n,&m)){
build(1,n,1);
char op[10];
for(int i=1;i<=m;i++){
scanf("%s",op);
if(op[0]=='Q'){
int x,y;
scanf("%d%d",&x,&y);
printf("%d\n",query(x,y,1,n,1));
}else{
int x,y;
scanf("%d%d",&x,&y);
update(x,y,1,n,1);
}
}
}
}