import sys from collections import Counter readline=sys.stdin.readline N,M=map(int,readline().split()) A=Counter(list(map(int,readline().split()))) B=list(map(int,readline().split())) for i in range(M): B[i]=A[B[i]] print(*B)