#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector s(n); map cnt; for (int i = 0; i < n; i++) { cin >> s[i]; for (int j = 0; j < s[i].size(); j++) { char org = s[i][j]; s[i][j] = '_'; cnt[s[i]]++; s[i][j] = org; } } for (int i = 0; i < n; i++) { int ans = 0; for (int j = 0; j < s[i].size(); j++) { char org = s[i][j]; s[i][j] = '_'; ans += cnt[s[i]] - 1; s[i][j] = org; } cout << ans << "\n"; } }