#include #include #include #include #include const int MAXN = 100000; using namespace std; int main() { int n; char ts[44]; map hash; map::iterator li; cin >> n; hash.clear(); for(int i = 0; i < n; i++){ scanf("%s",ts); int len = strlen(ts); sort(ts, ts + len); string tmp = (string)ts; li = hash.find(tmp); if(li==hash.end()){ cout << 0 << endl; hash[tmp]++; } else{ cout << hash[tmp] << endl; hash[tmp]++; } } return 0; }