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

public class list_bm {
    FastScanner in;
    PrintWriter out;

    int[][] next;
    int[] end;
    long[] ans;
    int cnt = 1;

    void addString(String s, int from, boolean first, int v) {
        if (s.length() == from) {
            end[v]++;
            return;
        }
        int c = s.charAt(from) - 'a';
        if (!first)
            c = s.charAt(s.length() - from - 1) - 'a';
        int nex = next[c][v];
        if (nex == -1) {
            next[c][v] = nex = cnt++;
        }
        if (first) {
            addString(s, from, !first, nex);
        } else {
            addString(s, from + 1, !first, nex);
        }
    }

    int getAns(int v, int h) {
        int sum = end[v];
        for (int i = 0; i < 26; i++)
            if (next[i][v] != -1)
                sum += getAns(next[i][v], h + 1);
        if (h % 2 == 0 && h > 1) {
            ans[(h / 2) - 1] += sum * 1L * (sum - 1) / 2;
        }
        return sum;
    }

    void solve() {
        int n = in.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++)
            s[i] = in.next();
        int su = 0;
        int ma = 0;
        for (int i = 0; i < n; i++) {
            ma = Math.max(ma, s[i].length());
            su += s[i].length();
        }
        out.println(ma);
        next = new int[26][su * 2 + 1];
        end = new int[su * 2 + 1];
        for (int i = 0; i < 26; i++)
            Arrays.fill(next[i], -1);
        for (int i = 0; i < n; i++) {
            addString(s[i], 0, true, 0);
        }
        ans = new long[ma];
        getAns(0, 0);
        for (int i = 0; i < ma; i++) {
            out.println(ans[i]);
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("list.in"));
            out = new PrintWriter(new File("list.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {
        new list_bm().run();
    }
}