#include #include #include #include using namespace std; int main() { int n; ios::sync_with_stdio(0); while (cin >> n) { map cnt; string temp; for (int i = 0; i < n; ++i) { cin >> temp; sort(temp.begin(), temp.end()); cout << cnt[temp] << endl; ++cnt[temp]; } } return 0; }