#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef pair PII; typedef vector VI; typedef vector VPII; typedef pair PLL; typedef pair PIL; typedef pair PLI; typedef double DB; #define pb push_back #define mset(a, b) memset(a, b, sizeof a) #define all(x) (x).begin(), (x).end() #define bit(x) (1 << (x)) #define bitl(x) (1LL << (x)) #define sqr(x) ((x) * (x)) #define sz(x) ((int)(x.size())) #define cnti(x) (__builtin_popcount(x)) #define cntl(x) (__builtin_popcountll(x)) #define clzi(x) (__builtin_clz(x)) #define clzl(x) (__builtin_clzll(x)) #define ctzi(x) (__builtin_ctz(x)) #define ctzl(x) (__builtin_ctzll(x)) #define X first #define Y second #define Error(x) cout << #x << " = " << x << endl template inline void chkmax(T& x, U y) { if (x < y) x = y; } template inline void chkmin(T& x, U y) { if (y < x) x = y; } const int MN = 1100000; const int MOD1 = 1e9 + 7; const int MOD2 = 1e9 + 9; int vn; PII v[MN], p[MN]; int cnt[MN], n; char s[105]; PII get() { scanf("%s", s); int n = strlen(s); PII ret; ret.X = 0, ret.Y = 0; sort(s, s + n); for (int i = 0; i < n; i++) { ret.X = ((LL)ret.X * 256 + s[i]) % MOD1; ret.Y = ((LL)ret.Y * 256 + s[i]) % MOD2; } return ret; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { v[vn++] = get(); p[i] = v[vn - 1]; } sort(v, v + vn); vn = unique(v, v + vn) - v; for (int i = 0; i < n; i++) { int pos = lower_bound(v, v + vn, p[i]) - v; printf("%d\n", cnt[pos]); cnt[pos]++; } return 0; }