package Test3;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
public class pCandidateName {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
Map<String,Integer> map = new LinkedHashMap<>();
int n= sc.nextInt();
for (int i =0; i <n; i++) {
map.put(sc.next(),0);
}
int voteNumber = sc.nextInt();
int invalid =0;
for (int j =0; j<voteNumber; j++) {
String vote = sc.next();
if (map.get(vote) == null) {
invalid++;
} else {
map.put(vote,map.get(vote)+1);
}
}
for (Map.Entry entry : map.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
System.out.println("Invalid : " + invalid);
}
}
}