#include int strcmp(char s[], char t[]) { int i = 0; for (;; i++) { if (s[i] == '\0' && t[i] == '\0') return 0; if (t[i] == '\0') return 1; if (s[i] == '\0') return -1; if (s[i] > t[i]) return 1; if (s[i] < t[i]) return -1; } } int h[2003], l; char s[2003][202]; int comp_h(int a, int b) { int r= strcmp(s[h[a]], s[h[b]]); if (r == 0) { if (h[a] < h[b]) r = 1; else r = -1; } return r; } void swap_h(int a, int b) { int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(int ne) { h[l] = ne; int p = l; l++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } int pop() { l--; swap_h(0, l); int p = 0; for (;;) { if (2 * p + 2 < l) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < l) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[l]; } int c[2003]; int sort_ind[2003]; int ans[11]; int main() { int n; scanf("%d", &n); int i; for (i = 0; i < n; i++) scanf("%s %d", s[i], &c[i]); l = 0; for (i = 0; i < n; i++) push(i); for (i = 0; i < n; i++) sort_ind[i] = pop(); for (i = 0; i < 8; i++) ans[i] = 0; ans[c[sort_ind[0]]]++; for (i = 1; i < n; i++) if (strcmp(s[sort_ind[i]], s[sort_ind[i - 1]]) != 0) ans[c[sort_ind[i]]]++; for (i = 0; i < 8; i++) printf("%d\n", ans[i]); return 0; }