#include #include #include #include #include #include #include using namespace std; char ch[50]; map q; int main() { int n; while( scanf( "%d" , &n ) != EOF ) { q.clear(); while( n-- ) { scanf( "%s" , ch ); int ln = strlen( ch ); sort( ch , ch + ln ); string str = (string)ch; int tm = q[str]; printf( "%d\n" , tm ); q[str] = tm+1; } } return 0; }