#include <string> #include<iostream> #include<cstring> #include<cstdio> #include<cstdlib> using namespace std; int n,m; int c[500005]; int lowbit(int x) { return (-x)&x; } void add(int pos,int x) { while(pos<=n) { c[pos]+=x; pos+=lowbit(pos); } } void input() { int x; for(int i=1; i<=n; i++) { scanf("%d",&x); add(i,x); } } int query(int pos) { int res=0; while(pos>0) { res+=c[pos]; pos-=lowbit(pos); } return res; } int main() { int t,cnt = 0; scanf("%d",&t); while(t--) { printf("Case %d:\n",++cnt); scanf("%d",&n); memset(c,0,sizeof(c)); input(); int x,y; string f; while(cin>>f&&f[0]!='E') { cin>>x>>y; if(f[0]=='A') add(x,y); else if(f[0]=='Q') cout<<query(y)-query(x-1)<<endl; else if(f[0]=='S') add(x,-1*y); } // if(t!=0)printf("\n"); } return 0; }