using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var s = SList(n); // var r = new Random(); // var n = 50000; // var s = new string[n]; // for (var i = 0; i < n; ++i) // { // var c = new char[10]; // for (var j = 0; j < 10; ++j) c[j] = (char)('a' + r.Next(26)); // s[i] = string.Concat(c); // } // var start = DateTime.Now; var tree = new TrieTree[10]; for (var i = 0; i < tree.Length; ++i) tree[i] = new TrieTree(); for (var i = 0; i < n; ++i) tree[s[i].Length - 1].Insert(s[i].ToCharArray()); var ans = new int[n]; for (var i = 0; i < n; ++i) { var ch = s[i].ToCharArray(); for (var j = 0; j < ch.Length; ++j) { for (var c = 'a'; c <= 'z'; ++c) { if (s[i][j] == c) continue; ch[j] = c; if (tree[s[i].Length - 1].Exists(ch)) ++ans[i]; } ch[j] = s[i][j]; } } WriteLine(string.Join("\n", ans)); // WriteLine(string.Join(" ", ans.Take(10))); // WriteLine((DateTime.Now - start).TotalSeconds); } class TrieTree { class Node { public char Val; public Node[] Next = new Node[26]; public Node(char val) { Val = val; } } Node Head = new Node('a'); public void Insert(char[] val) { var cur = Head; for (var i = 0; i < val.Length; ++i) { if (cur.Next[val[i] - 'a'] == null) cur.Next[val[i] - 'a'] = new Node(val[i]); cur = cur.Next[val[i] - 'a']; } } public bool Exists(char[] val) { var cur = Head; for (var i = 0; i < val.Length; ++i) { if (cur == null) return false; cur = cur.Next[val[i] - 'a']; } return cur != null; } } }