#include<stdio.h>
#include<string.h>
using namespace std;
int main() {
int n;
scanf_s("%d", &n);
bool sc[34];
memset(sc, false, 34);
int t[8];
int tr[7] = { 0 };
int cnt = 0;
for (int i = 1; i <= 7; ++i) {
scanf_s("%d", &t[i]);
sc[t[i]] = true;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= 7; ++j) {
scanf_s("%d", &t[j]);
if (sc[t[j]])cnt++;
}
tr[(7 - cnt) % 7]++;
cnt = 0;
}
for (int i = 0; i <= 6; ++i) {
printf("%d ", tr[i]);
}
return 0;
}