1 #include<stdio.h>
2 //#include<bits/stdc++.h>
3 #include<string.h>
4 #include<iostream>
5 #include<math.h>
6 #include<sstream>
7 #include<set>
8 #include<queue>
9 #include<map>
10 #include<vector>
11 #include<algorithm>
12 #include<limits.h>
13 #define inf 0x7fffffff
14 #define INFL 0x7fffffffffffffff
15 #define lson l,m,rt<<1
16 #define rson m+1,r,rt<<1|1
17 #define LL long long
18 #define ULL unsigned long long
19 using namespace std;
20 int main()
21 {
22 int t;
23 map<string,int> q;
24 char s[100000];
25 while(cin>>t)
26 {
27 while(t--)
28 {
29 scanf("%s",s);
30 int n=strlen(s);
31 sort(s,s+n);
32 q[s]++;
33 cout<<q[s]-1<<endl;
34 }
35 }
36 return 0;
37 }