import java.util.Scanner;
import java.util.LinkedHashMap;
//HashMap是无序的(只是说不是你插入时的顺序);
//LinkedHashMap是有序的(按你插入的顺序);
//TreeMap 是按key排序的;
//之前用hashmap不行,换成Linkedhaspmap
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
//候选人
int n = sc.nextInt();
//把\n读了
sc.nextLine();
LinkedHashMap<String,Integer> hm = new LinkedHashMap<String,Integer>();
for(int i = 0; i < n; i++){
String name = sc.next();
hm.put(name,0);
}
//sc.nextLine();
//投票
n = sc.nextInt();
//把\n读了
sc.nextLine();
int invalid = 0;
for(int i = 0;i < n; i++){
String vote = sc.next();
if(hm.containsKey(vote)){
hm.put(vote,hm.get(vote) + 1);
}else{
invalid++;
}
}
for(String key : hm.keySet()){
System.out.println(key + " : " + hm.get(key));
}
System.out.println("Invalid : " + invalid);
}
}
}