import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt(); // 小明买的彩票张数
int[] winningNumbers = new int[7];//中奖号码
for (int i = 0; i < 7; i++) {
winningNumbers[i] = scanner.nextInt(); // 中奖号码
}
int[] counts = new int[7]; // 用于记录不同等级中奖的张数
// 对每张彩票进行判断
for (int i = 0; i < n; i++) {
int[] ticket = new int[7];
for (int j = 0; j < 7; j++) {
ticket[j] = scanner.nextInt(); // 读取彩票号码
}
int ans = 0;
for (int j = 0; j < 7; j++) {
for (int k = 0; k < 7; k++) {
if (ticket[j] == winningNumbers[k]) {
ans++;
break;
}
}
}
// 根据匹配数目进行判断中奖情况
if (ans == 7) {
counts[0]++; // 特等奖
} else if (ans == 6) {
counts[1]++; // 一等奖
} else if (ans == 5) {
counts[2]++; // 二等奖
} else if (ans == 4) {
counts[3]++; // 三等奖
} else if (ans == 3) {
counts[4]++; // 四等奖
} else if (ans == 2) {
counts[5]++; // 五等奖
} else if (ans == 1) {
counts[6]++; // 六等奖
}
}
// 输出中奖情况
for (int count : counts) {
System.out.print(count + " ");
}
}
}