#include <iostream>
#include <cstring>
using namespace std;
int score[17] = {0,-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40,-100,100,50};
bool flag[17];
int sc[10];
int cal()
{
bool all = true;
for (int i = 1;i <= 13;i++)
{
if (flag[i] == false) all = false;
}
int s = 0;
if (all == false)
{
for (int i = 1;i <= 15;i++)
{
s += score[i] * flag[i];
}
}
else
{
s = 200;
if (flag[14] && flag[15]) s = 500;
s += flag[14] * score[14];
s += flag[15] * score[15];
}
if (flag[16] == true)
{
if (s == 0) s = 50;
else s *= 2;
}
return s;
}
int main()
{
int a = 1,b = 1,c = 1,d = 1;
while (true)
{
memset(sc,0,sizeof(sc));
int n;
for (int z = 1;z <= 4;z++)
{
if (z == 1)
{
cin >> a;
n = a;
}
if (z == 2)
{
cin >> b;
n = b;
}
if (z == 3)
{
cin >> c;
n = c;
}
if (z == 4)
{
cin >> d;
n = d;
}
if (a == 0 && b == 0 && c == 0 && d == 0) return 0;
memset(flag,0,sizeof(flag));
char y;
int x;
for (int i = 1;i <= n;i++)
{
cin >> y >> x;
if (y == 'H')
flag[x] = true;
if (y == 'S')
flag[14] = true;
if (y == 'D')
flag[15] = true;
if (y == 'C')
flag[16] = true;
}
sc[z] = cal();
}
for (int i = 1;i <= 4;i++)
{
if (sc[i] > 0) cout << "+" << sc[i] << " ";
else cout << sc[i] << " ";
}
cout << endl;
}
return 0;
}