#include<iostream>
#include<cstdio>
#include<string.h>
#include<string>
#include<stack>
#include<set>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#define ll __int64
#define lll unsigned long long
#define MAX 50009
#define eps 1e-8
#define INF 0xfffffff
#define mod 1000000007
using namespace std;
/*
题型:BIT
想法:直接搞喽
*/
int n;
int c[MAX];
int lowbit(int x)
{
return x&(-x);
}
void Insert(int x,int d)
{
while(x<=n)
{
c[x]+=d;
x+=lowbit(x);
}
}
int sum(int x)
{
int ret = 0;
while(x>0)
{
ret+=c[x];
x-=lowbit(x);
}
return ret;
}
void add(int x,int d)
{
while(x<=n)
{
c[x]+=d;
x+=lowbit(x);
}
}
int main()
{
char str[10];
int t;
int d = 1;
int x,y;
int xx;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(c,0,sizeof(c));//必须初始化好不好!
for(int i = 1; i<=n; i++)
{
scanf("%d",&xx);
Insert(i,xx);
}
printf("Case %d:\n",d++);
getchar();
while(1)
{
scanf("%s",str);
if(str[0]=='Q')
{
scanf("%d%d*c",&x,&y);
printf("%d\n",sum(y) - sum(x-1));
}
else if(str[0]=='A')
{
scanf("%d%d*c",&x,&y);
add(x,y);
}
else if(str[0]=='S')
{
scanf("%d%d*c",&x,&y);
add(x,-y);
}
else if(str[0]=='E')
{
break;
}
}
}
return 0;
}
#include<cstdio>
#include<string.h>
#include<string>
#include<stack>
#include<set>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#define ll __int64
#define lll unsigned long long
#define MAX 50009
#define eps 1e-8
#define INF 0xfffffff
#define mod 1000000007
using namespace std;
/*
题型:BIT
想法:直接搞喽
*/
int n;
int c[MAX];
int lowbit(int x)
{
return x&(-x);
}
void Insert(int x,int d)
{
while(x<=n)
{
c[x]+=d;
x+=lowbit(x);
}
}
int sum(int x)
{
int ret = 0;
while(x>0)
{
ret+=c[x];
x-=lowbit(x);
}
return ret;
}
void add(int x,int d)
{
while(x<=n)
{
c[x]+=d;
x+=lowbit(x);
}
}
int main()
{
char str[10];
int t;
int d = 1;
int x,y;
int xx;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(c,0,sizeof(c));//必须初始化好不好!
for(int i = 1; i<=n; i++)
{
scanf("%d",&xx);
Insert(i,xx);
}
printf("Case %d:\n",d++);
getchar();
while(1)
{
scanf("%s",str);
if(str[0]=='Q')
{
scanf("%d%d*c",&x,&y);
printf("%d\n",sum(y) - sum(x-1));
}
else if(str[0]=='A')
{
scanf("%d%d*c",&x,&y);
add(x,y);
}
else if(str[0]=='S')
{
scanf("%d%d*c",&x,&y);
add(x,-y);
}
else if(str[0]=='E')
{
break;
}
}
}
return 0;
}