import java.util.*;

/**
 * HJ94 记票统计
 */
public class HJ094 {

    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();
            //无效票数
            int invalid = 0;
            for (int i = 0; i < n; i++) {
                map.put(sc.next(), 0);
            }
            //投票人数
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                String key = sc.next();
                if (map.containsKey(key)) {
                    map.put(key, map.get(key) + 1);
                } else {
                    invalid++;
                }
            }
            for (String key : map.keySet()) {
                System.out.println(key + " : " + map.get(key));
            }
            System.out.println("Invalid" + " : " + invalid);
        }
        sc.close();
    }
}