from collections import defaultdict N, M = map(int, input().split(' ')) c = defaultdict(int) for a in map(int, input().split(' ')): c[a] += 1 for b in map(int, input().split(' ')): print(c[b], end=' ') print()