#include #include #include #include #include #include using namespace std; int main(int argc, char const *argv[]) { int n; map q; char buf[50]; while(~scanf("%d", &n)) { q.clear(); while(n--) { string t; cin >> t; sort(t.begin(), t.end()); if(!q.count(t)) { printf("0\n"); q[t] = 1; } else { printf("%d\n", q[t]); q[t]++; } } } return 0; }