#include #include #include #include using namespace std; #define N 1000005 #define ll unsigned long long int n,m,k,l; ll a[30]; mapmp; char st[N]; int main(){ scanf("%d",&n); for (int i=1;i<=n;i++){ scanf("%s",st+1); m=strlen(st+1); memset(a,0,sizeof(a)); for (int j=1;j<=m;j++)a[st[j]-65]++; ll s=0; for (int j=0;j<26;j++)s=s*6662333+a[j]; printf("%d\n",mp[s]); mp[s]++; } }