package boj;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public class boj_10816 {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
r.readLine();
Map<String, Long> myMap = Arrays.stream(r.readLine().split(" "))
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
r.readLine();
List<String> you = Arrays.stream(r.readLine().split(" "))
.collect(Collectors.toList());
for (String element : you) {
w.write(myMap.getOrDefault(element, 0L) + " ");
}
w.flush();
}
}