#include <fstream>
using namespace std;
ifstream cin("heart.in");
ofstream cout("heart.out");
int a,ji[55],s=0,r[5],h[14],i,j;
char hua[55];
bool hpyj(int x)
{
int i,o=0;
for (i=1;i<=x;i++)
if (hua[i]=='H'&&ji[i]==1||hua[i]=='H'&&ji[i]==2||hua[i]=='H'&&ji[i]==3||hua[i]=='H'&&ji[i]==4||hua[i]=='H'&&ji[i]==5||hua[i]=='H'&&ji[i]==6||hua[i]=='H'&&ji[i]==7||hua[i]=='H'&&ji[i]==8||hua[i]=='H'&&ji[i]==9||hua[i]=='H'&&ji[i]==10||hua[i]=='H'&&ji[i]==11||hua[i]=='H'&&ji[i]==12||hua[i]=='H'&&ji[i]==13)
o++;
if (o==13) return true;else return false;
}
bool wubaifen(int x)
{
int i,o=0;
for (i=1;i<=x;i++)
if (hua[i]=='H'&&ji[i]==1||hua[i]=='H'&&ji[i]==2||hua[i]=='H'&&ji[i]==3||hua[i]=='H'&&ji[i]==4||hua[i]=='H'&&ji[i]==5||hua[i]=='H'&&ji[i]==6||hua[i]=='H'&&ji[i]==7||hua[i]=='H'&&ji[i]==8||hua[i]=='H'&&ji[i]==9||hua[i]=='H'&&ji[i]==10||hua[i]=='H'&&ji[i]==11||hua[i]=='H'&&ji[i]==12||hua[i]=='H'&&ji[i]==13||hua[i]=='S'&&ji[i]==12||hua[i]=='D'&&ji[i]==11)
o++;
if (o==15) return true;else return false;
}
bool yiqianfen(int x)
{
int i,o=0;
for (i=1;i<=x;i++)
if (hua[i]=='H'&&ji[i]==1||hua[i]=='H'&&ji[i]==2||hua[i]=='H'&&ji[i]==3||hua[i]=='H'&&ji[i]==4||hua[i]=='H'&&ji[i]==5||hua[i]=='H'&&ji[i]==6||hua[i]=='H'&&ji[i]==7||hua[i]=='H'&&ji[i]==8||hua[i]=='H'&&ji[i]==9||hua[i]=='H'&&ji[i]==10||hua[i]=='H'&&ji[i]==11||hua[i]=='H'&&ji[i]==12||hua[i]=='H'&&ji[i]==13||hua[i]=='S'&&ji[i]==12||hua[i]=='D'&&ji[i]==11||hua[i]=='C'&&ji[i]==10)
o++;
if (o==16) return true;else return false;
}
void chu()
{
int i;
for (i=1;i<=4;i++) r[i]=0;
h[1]=-50;h[2]=-2;h[3]=-3;h[4]=-4;h[5]=-5;h[6]=-6;h[7]=-7;h[8]=-8;h[9]=-9;h[10]=-10;h[11]=-20;h[12]=-30;h[13]=-40;
}
int main()
{
chu();
while (s<4)
{
s=0;
for (i=1;i<=4;i++)
{
cin>>a;
if (a!=0)
{
for (j=1;j<=a;j++) cin>>hua[j]>>ji[j];
if (a==1&&hua[1]=='C'&&ji[1]==10) r[i]=50;
if (a>=13&&hpyj(a))
{
if (a>=15&&wubaifen(a)) r[i]=500;
if (a>=16&&yiqianfen(a)) r[i]=1000;
if (r[i]==0) r[i]=200;
}else
{
for (j=1;j<=a;j++)
{
if (hua[j]=='H') r[i]+=h[ji[j]];
if (hua[j]=='S'&&ji[j]==12) r[i]=r[i]-100;
if (hua[j]=='D'&&ji[j]==11) r[i]+=100;
}
for (j=1;j<=a;j++)
if (hua[j]=='C'&&ji[j]==10) r[i]=r[i]*2;
}
}else s++;
}
if (s!=4)
{
for (i=1;i<=4;i++)
if (r[i]>0) cout<<'+'<<r[i]<<' ';else
cout<<r[i]<<' ';
cout<<endl;
}
chu();
}
return 0;
}