//照它的逻辑写就行
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=null;
        while((s=br.readLine())!=null){
            int n=Integer.parseInt(s);
            String[] str=br.readLine().split(" ");
            int voteNums=Integer.parseInt(br.readLine());
            String[] voteStr=br.readLine().split(" ");
            int a[]=new int[n];
            int inValid=0;
            for(int i=0;i<voteNums;i++){
                int flag=0;
                for(int j=0;j<n;j++){
                    if(voteStr[i].equals(str[j])){
                        flag=1; 
                        a[j]++;
                        break;
                    } 
                }
                if(flag==0) inValid++;
            }
            for(int i=0;i<n;i++){
                System.out.println(str[i]+" : "+a[i]);
            }
            System.out.println("Invalid : "+inValid);
        }
    }
}