#include #include #define L(x) (x << 1)#define R(x) (x << 1|1)#define MAX 200000typedef struct{ int left; int right; int temp_max;}Node;Node node[3*MAX];int max;int getmax(int x,int y){ return x > 1; build(l,mid,L(k)); build(mid+1,r,R(k));}void insert(int pos,int val,int k){ if(pos >= node[k].left && pos <= node[k].right) { node[k].temp_max = getmax(val,node[k].temp_max); } if(node[k].left == node[k].right) return ; if(pos < node[R(k)].left) insert(pos,val,L(k)); else insert(pos,val,R(k));}int get_result(int l,int r,int k){ if(l == node[k].left && r == node[k].right) { return max = node[k].temp_max; } if(node[k].left == node[k].right) return max; if(r < node[R(k)].left) get_result(l,r,L(k)); else if(l > node[L(k)].right) return get_result(l,r,R(k)); else return max = getmax(get_result(l,node[L(k)].right,L(k)),get_result(node[R(k)].left,r,R(k)));}int main(){ int n,m,i,j,k; char str[5]; while(~scanf("%d%d",&n,&m)) { build(1,n,1); memset(str,0,sizeof(str)); for(i = 1;i <= n;i ++) { scanf("%d",&j); insert(i,j,1); } for(i = 1;i <= m;i ++) { scanf("%s",str); if(!strcmp(str,"Q")) { max = 0; scanf("%d%d",&j,&k); get_result(j,k,1); printf("%d\n",max); } else { scanf("%d%d",&j,&k); insert(j,k,1); } memset(str,0,sizeof(str)); } } return 0;}