s = input()
n = int(s)
x = list(map(int,input().split(" ")))
lis = [0,0,0,0,0,0,0]
for i in range(0,n):
s = list(map(int,input().split(" ")))
j = 0
for c in s:
if c in x:
j+=1
if j != 0:
lis[j-1] = lis[j-1]+1
for m in lis[::-1]:
print(i,end=" ")
求大佬告知为什么提交后结果都是RE