from collections import Counter input() counter = Counter(input().split()) input() print(' '.join(str(counter[n]) for n in input().split()))