line 1,colume 1,read 1,expected +.
#include<bits/stdc++.h>
using namespace std;
int change(string s){
if(s=="H1") return 1;
else if(s=="H2") return 2;
else if(s=="H3") return 3;
else if(s=="H4") return 4;
else if(s=="H5") return 5;
else if(s=="H6") return 6;
else if(s=="H7") return 7;
else if(s=="H8") return 8;
else if(s=="H9") return 9;
else if(s=="H10") return 10;
else if(s=="H11") return 11;
else if(s=="H12") return 12;
else return 13;
}
int main(){
while(1){
int a,b,c,d,sa=0,sb=0,sc=0,sd=0,hcnt[5]={},hmark[5][14]={},hs[14]={0,-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40};
string point[5][17]={};
int c10,d11,s12;
scanf("%d",&a);
for(int i=1;i<=a;i++){
cin>>point[1][i];
if(point[1][i]=="C10") c10=1;
if(point[1][i]=="D11"||point[1][i]=="D10") d11=1;
if(point[1][i]=="S12") s12=1;
if(point[1][i][0]=='H'){
hcnt[1]++;
hmark[1][hcnt[1]]=change(point[1][i]);
}
}
scanf("%d",&b);
for(int i=1;i<=b;i++){
cin>>point[2][i];
if(point[2][i]=="C10") c10=2;
if(point[2][i]=="D11"||point[2][i]=="D10") d11=2;
if(point[2][i]=="S12") s12=2;
if(point[2][i][0]=='H'){
hcnt[2]++;
hmark[2][hcnt[2]]=change(point[2][i]);
}
}
scanf("%d",&c);
for(int i=1;i<=c;i++){
cin>>point[3][i];
if(point[3][i]=="C10") c10=3;
if(point[3][i]=="D11"||point[3][i]=="D10") d11=3;
if(point[3][i]=="S12") s12=3;
if(point[3][i][0]=='H'){
hcnt[3]++;
hmark[3][hcnt[3]]=change(point[3][i]);
}
}
scanf("%d",&d);
for(int i=1;i<=d;i++){
cin>>point[4][i];
if(point[4][i]=="C10") c10=4;
if(point[4][i]=="D11"||point[4][i]=="D10") d11=4;
if(point[4][i]=="S12") s12=4;
if(point[4][i][0]=='H'){
hcnt[4]++;
hmark[4][hcnt[4]]=change(point[4][i]);
}
}
if(a==0&&b==0&&c==0&&d==0) break;
if(a==16){
printf("1000 0 0 0\n");
continue;
}
if(b==16){
printf("0 1000 0 0\n");
continue;
}
if(c==16){
printf("0 0 1000 0\n");
continue;
}
if(d==16){
printf("0 0 0 1000\n");
continue;
}
if(hcnt[1]==13){
sa+=200;
if(s12==1&&d11==1) sa=500;
else{
if(s12==1&&d11!=1) sa-=100;
if(d11==1&&s12!=1) sa+=100;
}
}else{
for(int i=1;i<=hcnt[1];i++) sa+=hs[hmark[1][i]];
if(s12==1) sa-=100;
if(d11==1) sa+=100;
}
if(hcnt[2]==13){
sb+=200;
if(s12==2&&d11==2) sb=500;
else{
if(s12==2&&d11!=2) sb-=100;
if(d11==2&&s12!=2) sb+=100;
}
}else{
for(int i=1;i<=hcnt[2];i++) sb+=hs[hmark[2][i]];
if(s12==2) sb-=100;
if(d11==2) sb+=100;
}
if(hcnt[3]==13){
sc+=200;
if(s12==3&&d11==3) sc=500;
else{
if(s12==3&&d11!=3) sc-=100;
if(d11==3&&s12!=3) sc+=100;
}
}else{
for(int i=1;i<=hcnt[3];i++) sc+=hs[hmark[3][i]];
if(s12==3) sc-=100;
if(d11==3) sc+=100;
}
if(hcnt[4]==13){
sd+=200;
if(s12==4&&d11==4) sd=500;
else{
if(s12==4&&d11!=4) sd-=100;
if(d11==4&&s12!=4) sd+=100;
}
}else{
for(int i=1;i<=hcnt[4];i++) sd+=hs[hmark[4][i]];
if(s12==4) sd-=100;
if(d11==4) sd+=100;
}
if(c10==1&&a>=2) sa*=2;
if(c10==2&&b>=2) sb*=2;
if(c10==3&&c>=2) sc*=2;
if(c10==4&&d>=2) sd*=2;
if(c10==1&&a==1) sa=50;
if(c10==2&&b==1) sb=50;
if(c10==3&&c==1) sc=50;
if(c10==4&&d==1) sd=50;
if(sa>0) printf("+%d ",sa);
else printf("%d ",sa);
if(sb>0) printf("+%d ",sb);
else printf("%d ",sb);
if(sc>0) printf("+%d ",sc);
else printf("%d ",sc);
if(sd>0) printf("+%d\n",sd);
else printf("%d\n",sd);
}
return 0;
}