JAVA
HashMap + list
map.containsKey
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
while (in.hasNext()){
int va = 0;
int n = in.nextInt();
LinkedList<String> list = new LinkedList<>();
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < n; i++){
String cur = in.next();
list.add(cur);
map.put(cur, 0);
}
int n2 = in.nextInt();
for (int i = 0; i < n2; i++){
String cur = in.next();
if (map.containsKey(cur)){
map.put(cur, map.get(cur) + 1);
}else{
va++;
}
}
for (int i = 0; i < n; i++){
String k = list.get(i);
int v = map.get(k);
System.out.println(k + " : " + v);
}
System.out.println("Invalid" + " : " + va);
}
}
}