#include<stdio.h>
main()
{
int n;
int PrizeNumber[7];
int a[34];
int BuyNumber[1001][7];
scanf("%d",&n);
int count[1001]={0};
int Prize[7];
for(int i=0;i<7;i++)
{
scanf("%d",&PrizeNumber[i]);
}
for(int i=0;i<7;i++)
{
a[PrizeNumber[i]]=1;
}
for(int i=0;i<n;i++){
for(int j=0;j<7;j++)
{
scanf("%d",&BuyNumber[i][j]);
if(a[BuyNumber[i][j]]==1)
{
count[i]++;
}
}
}
for(int i=0;i<n;i++)
{
if(count[i]==7)
{
Prize[0]++;
}
if(count[i]==6)
{
Prize[1]++;
}
if(count[i]==5)
{
Prize[2]++;
}
if(count[i]==4)
{
Prize[3]++;
}
if(count[i]==3)
{
Prize[4]++;
}
if(count[i]==2)
{
Prize[5]++;
}
if(count[i]==1)
{
Prize[6]++;
}
}
for(int i=0;i<7;i++)
{
printf("%d ",Prize[i]);
}
}