#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MEM(a,b) memset(a,b,sizeof(a)) #define MP(a,b) make_pair(a,b) #define PB push_back typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const int mod = 1e9 + 7; int N; int cnt[30]; map mp; char s[50]; int main(){ while(scanf("%d",&N) != EOF){ mp.clear(); for(int i = 1; i <= N; ++i){ scanf("%s",s); int len = strlen(s); sort(s,s + len); int hash = 0; for(int j = 0; s[j]; ++j){ hash = (1ll * hash * 173 + s[j]) % mod; } printf("%d\n",mp[hash]); mp[hash]++; } } return 0; }