/**
HDU 1166 ZKW线段树
https://vjudge.net/problem/HDU-1166
区间和+单点更新
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5+7;
int M,n,a[maxn<<2];
int d[maxn<<2];
//下标为1,询问区间和[l,r]:贡献:l的右儿子,r的左儿子;
int query(int l,int r){
int ans=0;
l+=M-1,r+=M+1;
for(;l^r^1;l>>=1,r>>=1){
if(l&1^1) ans+=d[l^1];//l的右儿子
if(r&1) ans+=d[r^1];//r的左儿子
}
return ans;
}
//单点修改d[x] += val ;
void add(int x,int val){
x+=M;
d[x]+=val;x>>=1;
for(;x;x>>=1) d[x]=d[x<<1]+d[x<<1|1];//一层一层的往上面进行更新;
}
char op[20];
int main (){
int t;scanf("%d",&t);
for(int cas=1;cas<=t;cas++){
scanf("%d",&n);for(M=1;M<n;M<<=1);
memset(d,0,sizeof(d));
for(int i=M+1;i<=M+n;i++) scanf("%d",&d[i]);
for(int i=M-1;i>=1;i--) d[i]=d[i<<1]+d[i<<1|1];
printf("Case %d:\n",cas);
while(~scanf("%s",op)&&strcmp(op,"End")!=0) {
int l,r;scanf("%d %d",&l,&r);
if(op[0]=='Q') printf("%d\n",query(l,r));
else if(op[0]=='A') add(l,r);
else add(l,-r);
}
}
return 0;
}
/**
9
7
1 2 1 2 2 3 4
Query 2 7
*/