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