import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine(); //nextInt()后不能直接使用nextLine(),因为nextInt()的回车符还在缓存中,需要先取出
String[] str = sc.nextLine().split(" ");
Map<String,Integer> hash = new LinkedHashMap<>(); //用链表hash就可以按照输入顺序输出
for(String s:str){
hash.put(s,0);
}
int m = sc.nextInt();
sc.nextLine();
int invalid = 0;
String[] str2 = sc.nextLine().split(" ");
for(String s:str2){
if(hash.containsKey(s)){
hash.put(s,hash.get(s)+1);
}else{
invalid++;
}
}
for(String s:hash.keySet()){
System.out.println(s+" : "+hash.get(s));
}
System.out.println("Invalid : "+invalid);
}
}