n = int(input())
zj = list(map(int,(input().split())))
cp = []
sc = []
jg = []
one=0
two=0
three=0
four=0
five=0
six = 0
seven = 0
sum = 0
for i in range(n):
s = list(map(int,(input().split())))
cp .append(s)
for l in range(len(cp)):
sum = 0
for j in range(7):
for k in range(len(zj)):
if cp[l][j] == zj[k]:
sum = sum + 1
sc.append(sum)
for n in range(len(sc)):
if sc[n] == 7:
seven = seven +1
elif sc[n] == 6:
six = six + 1
elif sc[n] == 5:
five = five + 1
elif sc[n] == 4:
four = four + 1
elif sc[n] == 3:
three = three + 1
elif sc[n] == 2:
two = two + 1
else:
one = one + 1
print("{} {} {} {} {} {} {}".format(seven,six,five,four,three,two,one),end="")