#include<stdio.h>
int main()
{
int n,a[8]={0},b[8]={0};
int i,j,k;
int count[1000]={0};
int count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0;
scanf("%d",&n);
for(i=1;i<=7;++i)
{
scanf("%d",&a[i]);
}
for(j=1;j<=n;++j)
{
for(k=1;k<=7;++k)
{
scanf("%d",&b[k]);
}
for(i=1;i<=7;++i)
{
for(k=1;k<=7;++k)
{
if(a[i]==b[k])
{
count[j]++;
}
}
}
}
for(j=1;j<=n;++j)
{
if(count[j]==7)
{
count1++;
}
if(count[j]==6)
{
count2++;
}
if(count[j]==5)
{
count3++;
}
if(count[j]==4)
{
count4++;
}
if(count[j]==4)
{
count5++;
}
if(count[j]==2)
{
count6++;
}
if(count[j]==1)
{
count7++;
}
}
printf("%d %d %d %d %d %d %d",count1,count2,count3,count4,count5,count6,count7);
return 0;
}