import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); ArrayList> names = new ArrayList<>(); for (int i = 0; i <= 10; i++) { names.add(new ArrayList<>()); } for (int i = 0; i < n; i++) { Name x = new Name(i, sc.next().toCharArray()); names.get(x.length()).add(x); } int[] ans = new int[n]; for (int i = 1; i <= 10; i++) { ArrayList tmp = names.get(i); for (int j = 0; j < i; j++) { HashMap> group = new HashMap<>(); Name.mask = j; for (Name x : tmp) { if (!group.containsKey(x)) { group.put(x, new ArrayList<>()); } group.get(x).add(x.idx); } for (ArrayList x : group.values()) { if (x.size() <= 1) { continue; } for (int y : x) { ans[y] += x.size() - 1; } } } } StringBuilder sb = new StringBuilder(); for (int x : ans) { sb.append(x).append("\n"); } System.out.print(sb); } static class Name { static int mask; int idx; char[] arr; public Name(int idx, char[] arr) { this.idx = idx; this.arr = arr; } public int length() { return arr.length; } public int hashCode() { return length(); } public boolean equals(Object o) { Name n = (Name)o; for (int i = 0; i < arr.length; i++) { if (mask == i) { continue; } if (arr[i] != n.arr[i]) { return false; } } return true; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }