import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            Map<String, Integer> map = new LinkedHashMap<>();
            for (int i = 0; i < n; i++) {
                map.put(sc.next(), 0);
            }
            int m = sc.nextInt();
            int invalidCount = 0;
            for (int i = 0; i < m; i++) {
                String name = sc.next();
                if (map.containsKey(name)) {
                    map.put(name, map.get(name) + 1);
                } else {
                    invalidCount++;
                }
            }
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                System.out.println(entry.getKey() + " : " + entry.getValue());
            }
            System.out.println("Invalid : " + invalidCount);
        }
        sc.close();
    }

}