// @BEGIN_OF_SOURCE_CODE

/* @JUDGE_ID: 17243NT 178 C++ */

// Send to judge@uva.es

#include <iostream.h>

#include <fstream.h>

#include <iomanip.h>

#ifdef ONLINE_JUDGE

#define ins cin

#define outs cout

#else

#define ins fin

#define outs fout

ifstream fin("myprog.in");

ofstream fout("myprog.out");

#endif

int totals[16], nfilled;

int tops[16];

int cards[52];

int findcard(int n);

int main() {

char c, d;

int i, j;

int num = 0;

while(ins >> c) {

if(c == '#') break;

ins.putback(c);

for(i = 0; i < 52; i++) {

ins >> c >> d;

if(c == 'T')

cards

*= 10;*

else if(c == 'J')

cards

else if(c == 'J')

cards

*= 11;*

else if(c == 'Q')

cardselse if(c == 'Q')

cards

*= 12;*

else if(c == 'K')

cardselse if(c == 'K')

cards

*= 13;*

else if(c == 'A')

cardselse if(c == 'A')

cards

*= 1;*

else cardselse cards

*= c - '0';*

}

nfilled = 0;

for(i = 0; i < 52; i++) {

for(j = 0; j < nfilled; j++) {

if(tops[j] < 11) {

int f = findcard(11 - tops[j]);

if(f >= 0) {

totals[j]++;

tops[j] = cards[i++];

if(i >= 52) break;

totals[f]++;

tops[f] = cards}

nfilled = 0;

for(i = 0; i < 52; i++) {

for(j = 0; j < nfilled; j++) {

if(tops[j] < 11) {

int f = findcard(11 - tops[j]);

if(f >= 0) {

totals[j]++;

tops[j] = cards[i++];

if(i >= 52) break;

totals[f]++;

tops[f] = cards

*;*

break;

}

} else {

int g, h;

if(tops[j] == 11)

g = findcard(12), h = findcard(13);

if(tops[j] == 12)

g = findcard(11), h = findcard(13);

if(tops[j] == 13)

g = findcard(11), h = findcard(12);

if(g >= 0 && h >= 0) {

totals[j]++;

tops[j] = cards[i++];

if(g < h) {

if(i >= 52) break;

totals[g]++;

tops[g] = cards[i++];

if(i >= 52) break;

totals[h]++;

tops[h] = cardsbreak;

}

} else {

int g, h;

if(tops[j] == 11)

g = findcard(12), h = findcard(13);

if(tops[j] == 12)

g = findcard(11), h = findcard(13);

if(tops[j] == 13)

g = findcard(11), h = findcard(12);

if(g >= 0 && h >= 0) {

totals[j]++;

tops[j] = cards[i++];

if(g < h) {

if(i >= 52) break;

totals[g]++;

tops[g] = cards[i++];

if(i >= 52) break;

totals[h]++;

tops[h] = cards

*;*

} else {

if(i >= 52) break;

totals[h]++;

tops[h] = cards[i++];

if(i >= 52) break;

totals[g]++;

tops[g] = cards} else {

if(i >= 52) break;

totals[h]++;

tops[h] = cards[i++];

if(i >= 52) break;

totals[g]++;

tops[g] = cards

*;*

}

break;

}

}

}

if(i >= 52) break;

if(j >= nfilled) {

if(nfilled >= 16) break;

totals[nfilled] = 1;

tops[nfilled++] = cards}

break;

}

}

}

if(i >= 52) break;

if(j >= nfilled) {

if(nfilled >= 16) break;

totals[nfilled] = 1;

tops[nfilled++] = cards

*;*

}

}

outs << ++num << ":";

if(i >= 52) {

for(i = 0; i < nfilled; i++)

outs << setw(3) << totals[i];

outs << endl;

} else {

outs << " Overflowed on card no " << i++ << endl;

}

}

return 0;

}

int findcard(int n) {

int j;

for(j = 0; j < nfilled; j++)

if(tops[j] == n) return j;

return -1;

}

// @END_OF_SOURCE_CODE}

}

outs << ++num << ":";

if(i >= 52) {

for(i = 0; i < nfilled; i++)

outs << setw(3) << totals[i];

outs << endl;

} else {

outs << " Overflowed on card no " << i++ << endl;

}

}

return 0;

}

int findcard(int n) {

int j;

for(j = 0; j < nfilled; j++)

if(tops[j] == n) return j;

return -1;

}

// @END_OF_SOURCE_CODE