#include <cstdio>
#include<iostream>using namespace std;
struct Node{
int left,right,value;
}st[150010];
int a[150010];
int T,n;
void build(int left,int right,int root){
st[root].left=left;
st[root].right=right;
if(left==right){
st[root].value=a[left];
return;
}
int mid=(left+right)/2;
build(left,mid,2*root);
build(mid+1,right,2*root+1);
st[root].value=st[root*2].value+st[2*root+1].value;
}
void update(int idx,int val,int root){
if(st[root].left==st[root].right){
st[root].value+=val;
return;
}
st[root].value+=val;
if(idx<=st[root*2].right)
update(idx,val,root*2);
else
update(idx,val,root*2+1);
}
int query(int left,int right,int root){
if(st[root].left==left&&st[root].right==right){
return st[root].value;
}
int mid=(st[root].left+st[root].right)/2;
if(right<=mid){
return query(left,right,2*root);
}else if(left>mid){
return query(left,right,2*root+1);
}else
return query(left,mid,root*2)+query(mid+1,right,root*2+1);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int i,t1,t2;
char s[10];
scanf("%d",&T);
for(int k=1;k<=T;k++)
{
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
build(1,n,1);
printf("Case %d:\n",k);
while(1)
{
scanf("%s",s);
if(strcmp(s,"End")==0) break;
scanf("%d%d",&t1,&t2);
if(strcmp(s,"Query")==0)
{
int ans=query(t1,t2,1);
printf("%d\n",ans);
}
if(strcmp(s,"Sub")==0) update(t1,-t2,1);
if(strcmp(s,"Add")==0) update(t1,t2,1);
}
}
return 0;
}