import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int N = kb.nextInt();
HashMap<Integer, Integer> map = new HashMap<>();
for(int i= 0; i<N; i++) {
int x = kb.nextInt();
map.put(x, map.getOrDefault(x, 0)+1);
}
StringBuilder sb = new StringBuilder();
int M = kb.nextInt();
for(int i=0; i<M; i++) {
int x = kb.nextInt();
if(map.containsKey(x)) {
sb.append(map.get(x)).append(" ");
}else {
sb.append(0).append(" ");
}
}
System.out.println(sb.toString());
}
}