import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Section052 {
	static class member {
		int dong, nai;
		String irum;
	}
	public static void main(String[] args) throws IOException {
		Scanner scanf = new Scanner(System.in);
		FileWriter ouf = new FileWriter("result3.txt");
		member data = new member();
		int a[][] = new int[11][8];
		int i, j, row, col;
		for (i = 0; i <= 10; i++)
			for (j = 0; j <= 7; j++)
				a[i][j] = 0;
		System.out.printf("동 이름 나이를 입력하세요.\n모두 입력하셨으면 '0 0 0'을 입력하세요\n");
		while (true)
		{
			data.dong = scanf.nextInt();
			data.irum = scanf.next();
			data.nai = scanf.nextInt();
			if (data.dong == 0)
				break;
			if (data.nai >= 60)
				data.nai = 60;
			row = data.dong - 1;
			col = data.nai / 10;
			a[row][col] += 1;
			a[row][7] += 1;
			a[10][col] += 1;
			a[10][7] += 1;
		}
		for (i = 0; i <= 10; i++)
		{
			for (j = 0; j <= 7; j++)
				ouf.write(String.format(" %d", a[i][j]));
			ouf.write(String.format("\r\n"));
		}
		scanf.close();
		ouf.close();
	}
}
