#include <stdio.h>
#define NUMLEN (10)
char NUM[NUMLEN][4] =
{
"ZRO", "ONE", "TWO", "THR", "FOR", "FIV", "SIX", "SVN", "EGT", "NIN"
};
char buf[10000 + 1];
int T, test;
int cTABLE[NUMLEN];
int ATI(char* str) {
switch (*str) {
case 'Z': return 0;
case 'O': return 1;
case 'E': return 8;
case 'N': return 9;
case 'T':
{
if (str[1] == 'H') return 3;
else return 2;
}
case 'F' :
{
if (str[1] == 'I') return 5;
else return 4;
}
case 'S' :
{
if (str[1] == 'I') return 6;
else return 7;
}
break;
}
return -1;
}
void input(void)
{
int tCount, count = 0;
scanf("%*s %d", &tCount);
while (count < tCount) {
scanf("%s", buf);
++cTABLE[ATI(buf)];
++count;
}
}
void output(void)
{
int i;
printf("#%d\n", test);
for (i = 0; i < NUMLEN; ++i)
{
while (cTABLE[i] > 0)
{
--cTABLE[i];
printf("%s ", NUM[i]);
}
}
puts("");
}
int main(void)
{
freopen("input.txt", "r", stdin);
scanf("%d", &T);
for (test = 1; test <= T; ++test)
{
input();
output();
}
return 0;
}
댓글