import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int cnt = 0;
        Map<String, Integer> hs = new LinkedHashMap<>();
        int n = in.nextInt();
        String[] s1 = new String[n];
        in.nextLine();
        for(int i = 0; i<n; i++){
            s1[i] = in.next();
            hs.put(s1[i],0);
        }
        int a = in.nextInt();
        String[] s2 = new String[a];    
        in.nextLine();
        for(int i = 0; i<s2.length; i++){
            s2[i] = in.next();
            if(hs.containsKey(s2[i])){
                hs.put(s2[i],hs.get(s2[i])+1);
            }else{
                cnt++;
            }
        }
        for(Map.Entry<String,Integer> e : hs.entrySet()){
            System.out.println(e.getKey()+" : "+e.getValue());
        }
        System.out.println("Invalid : "+cnt);
    }
}