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(); HashMap> group = new HashMap<>(); for (int i = 0; i < n; i++) { char[] values = sc.next().toCharArray(); for (int j = 0; j < values.length; j++) { char c = values[j]; values[j] = '.'; Name x = new Name(i, new String(values)); if (!group.containsKey(x)) { group.put(x, new ArrayList<>()); } group.get(x).add(x.idx); values[j] = c; } } int[] ans = new int[n]; for (ArrayList list : group.values()) { for (int x : list) { ans[x] += list.size() - 1; } } StringBuilder sb = new StringBuilder(); for (int x : ans) { sb.append(x).append("\n"); } System.out.print(sb); } static class Name { int idx; String s; public Name(int idx, String s) { this.idx = idx; this.s = s; } public int hashCode() { return s.hashCode(); } public boolean equals(Object o) { Name n = (Name)o; return s.equals(n.s); } } } 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(); } }