#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair PII; #define fi first #define se second #define MP make_pair int read() { int v = 0, f = 1; char c = getchar(); while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();} while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar(); return v * f; } const int N = 10000; int n, q; char ch[N]; int c[N]; string cha; map mp; int main() { scanf("%d", &q); for (int i = 1; i <= q; i++) { memset(ch, 0, sizeof ch); scanf("%s", ch + 1); n = strlen(ch + 1); for (int i = 1; i <= n; i++) c[i] = ch[i]; sort(c + 1, c + n + 1); for (int i = 1; i <= n; i++) ch[i] = c[i]; cha = ch + 1; printf("%d\n", mp[cha]++); } }