#include <iostream>
#include <cstdio>
using namespace std;
bool flag;
int read_and_compute()
{
bool cards[4][14] = {};
enum {S, H, D, C};
int n;
cin >> n;
flag = flag || n;
for (int i = 0; i < n; i++)
{
char a;
int b;
cin >> a >> b;
switch (a)
{
case 'S': a = S; break;
case 'H': a = H; break;
case 'D': a = D; break;
case 'C': a = C; break;
}
cards[a][b] = true;
}
int scores = 0;
if (cards[H][1] && cards[H][2] && cards[H][3] && cards[H][4] && cards[H][5] && cards[H][6] && cards[H][7] &&
cards[H][8] && cards[H][9] && cards[H][10] && cards[H][11] && cards[H][12] && cards[H][13])
{
scores += 200;
if (cards[D][11] && cards[S][12])
scores += 300;
else
scores += 100 * cards[D][11] - 100 * cards[S][12];
}
else
scores += 100 * cards[D][11] - 100 * cards[S][12] - 50 * cards[H][1] - 2 * cards[H][2] - 3 * cards[H][3] -
4 * cards[H][4] - 5 * cards[H][5] - 6 * cards[H][6] - 7 * cards[H][7] - 8 * cards[H][8] - 9 * cards[H][9] -
10 * cards[H][10] - 20 * cards[H][11] - 30 * cards[H][12] - 40 * cards[H][13];
if (cards[C][10])
{
if (n == 1)
scores += 50;
else
scores *= 2;
}
return scores;
}
int main()
{
while (true)
{
flag = false;
int a = read_and_compute(), b = read_and_compute(), c = read_and_compute(), d = read_and_compute();
if (!flag)
break;
printf(a ? "%+d " : "%d ", a);
printf(b ? "%+d " : "%d ", b);
printf(c ? "%+d " : "%d ", c);
printf(d ? "%+d " : "%d\n", d);
}
return 0;
}