/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static List<Integer> sol(String[]s){
		int n=s.length;
		List<Integer>res=new ArrayList<>(n);
		for(int i=0;i<n;i++){
			res.add(0);
		}
		int g[][]=new int[200005][26];
		for(int i=n-1;i>=0;i--){
			String u=s[i];
			int count=0;
			for(int j=0;j<u.length();j++){
				char c=s[i].charAt(j);
				count=count+g[j][c-'a'];
				g[j][c-'a']++;
			}
			res.set(i,count);
		}
		return res;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s[]=new String[n];
		for(int i=0;i<n;i++){
			s[i]=sc.next();
		}
		List<Integer>res=sol(s);
		System.out.println(res);
	}
}