import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.valueOf(scan.nextLine().trim());
        String[] names = scan.nextLine().split(" ");
        int m = Integer.valueOf(scan.nextLine().trim());
        String[] votes = scan.nextLine().split(" ");
        HashMap<String, Integer> hashMap = new HashMap<>();
        for (String name : names) {
            hashMap.put(name, 0);
        }
        int inValid = 0;
        for (String vote : votes) {
            int tmpV = hashMap.getOrDefault(vote, -1);
            if (tmpV == -1) {
                inValid++;
            } else {
                tmpV++;
                hashMap.put(vote, tmpV);
            }
        }
        for (String name : names) {
            System.out.println(name + " : " + hashMap.get(name));
        }
        System.out.println("Invalid : " + inValid);
    }
}