// Arup Guha
// 1/7/2016
// Solution to 2016 Dec USACO Bronze Problem: Square

import java.util.*;
import java.io.*;

public class blocks {

	public static void main(String[] args) throws Exception {

		// Open file.
		BufferedReader stdin = new BufferedReader(new FileReader("blocks.in"));
		int n = Integer.parseInt(stdin.readLine());

		// Set up initial frequencies.
		int[] freq = new int[26];

		// Process pairs of words.
		for (int i=0; i<n; i++) {
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			String s = tok.nextToken();
			String t = tok.nextToken();

			// Just get the max of each letter frequency and add.
			int[] max = getMaxFreq(s, t);
			add(freq, max);
		}

		// Ta da!
		PrintWriter out = new PrintWriter(new FileWriter("blocks.out"));
		for (int i=0; i<26; i++)
			out.println(freq[i]);
		out.close();
		stdin.close();
	}

	// Adds in values of b into a, both arrays must be length 26.
	public static void add(int[] a, int[] b) {
		for (int i=0; i<26; i++)
			a[i] += b[i];
	}

	// Returns the max frequency array for s and t.
	public static int[] getMaxFreq(String s, String t) {
		int[] f1 = getFreq(s);
		int[] f2 = getFreq(t);
		int[] res = new int[26];
		for (int i=0; i<26; i++)
			res[i] = Math.max(f1[i], f2[i]);
		return res;
	}

	// Returns frequency array of letter frequecies of s (all lower case).
	public static int[] getFreq(String s) {
		int[] res = new int[26];
		for (int i=0; i<s.length(); i++)
			res[s.charAt(i)-'a']++;
		return res;
	}
}