#include #include #include #include using namespace std; inline void print(int pt) { printf("%d\n", pt); } inline void print(long long pt) { printf("%I64d\n", pt); } inline void print(double pt) { printf("%f\n", pt); } inline void print(char pt[]) { printf("%s\n", pt); } inline void print(char pt) { printf("%c\n", pt); } inline void scan(int &pt) { scanf("%d", &pt); } inline void scan(long long &pt) { scanf("%I64d", &pt); } inline void scan(double &pt) { scanf("%lf", &pt); } inline void scan(char pt[]) { scanf("%s", pt); } struct pii { int a; int b; friend int operator<(pii a, pii b) { if (a.a != b.a) return a.a < b.a; return a.b < b.b; } }; struct piii { int quest; int time; int index; friend int operator<(piii a, piii b) { if (a.quest != b.quest) return a.quest > b.quest; return a.time < b.time; } }; class str { public: char strr[30]; str() { memset(strr, 0, sizeof(strr)); } friend int operator<(str a, str b) { return strcmp(a.strr, b.strr) < 0; } friend int operator==(str a, str b) { int lena = sizeof(a.strr) / sizeof(char); for (int i = 0; i < lena; i++) { if (a.strr[i] != b.strr[i]) return 0; } return 1; } }; int bits[50]; void getbits() { for (int i = 0; i < 50; i++) { bits[i] = 1 << i; } } long long HASH = 1414732762971465ll; struct pp { int nums[200]; long long gethash() { long long a = 0; for (int i = 0; i < 200; i++) { a *= 40; a += nums[i]; a %= HASH; } return a; } pp() { memset(nums, 0, sizeof(nums)); } friend int operator<(pp a, pp b) { for (int i = 0; i < 200; i++) { if (a.nums[i] != b.nums[i]) return a.nums[i] < b.nums[i]; } return 0; } }; int n; char stra[1000010]; map mapa; int main() { scan(n); while (n--) { pp tp = pp(); scan(stra); int lena = strlen(stra); for (int i = 0; i < lena; i++) { tp.nums[stra[i]]++; } long long tll = tp.gethash(); print(mapa[tll]); mapa[tll]++; } return 0; }