N = int(input())
N_lst = list(map(int, input().split()))
M = int(input())
M_lst = list(map(int, input().split()))
dict = {}
for i in M_lst:
dict[i] = 0
for i in N_lst:
try:
dict[i] += 1
except KeyError:
continue
for i in M_lst:
print(dict[i], end=" ")