#include <stdio.h>
#include <string.h>
//名字可以再长一点,手动狗头
int main()
{
int n;
while (scanf("%d", &n) != EOF)
{
char name[n][100];
for (int i = 0; i < n; i++)
{
scanf("%s", name[i]);
}
int vote, illegal_count = 0;
int count[n];
for (int i = 0; i < n; i++)
count[i] = 0;
scanf("%d", &vote);
char vote_name[100] = {'\0'};
for (int i = 0; i < vote; i++)
{
scanf("%s", vote_name);
int illegal = 1; //合法0,非法1
for (int j = 0; j < n; j++)
{
if (strcmp(name[j], vote_name) == 0)
{
illegal = 0;
count[j]++;
break;
}
}
if (illegal)
illegal_count++;
}
for (int i = 0; i < n; i++)
{
printf("%s : %d\n", name[i], count[i]);
}
printf("Invalid : %d\n", illegal_count);
}
return 0;
}