#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define F1(x,y,z) for(int x=y;xz;x--) #define F4(x,y,z) for(int x=y;x>=z;x--) #define pb push_back #define LL long long #define co complex #define MAX 100005 #define AMAX 1500 #define MOD 1000000007 #define f(c,d) ((1<<(c))*(d)) using namespace std; int n,i; vector vt; map,int> m; map,int>::iterator it; char x[50]; int main(){ scanf("%d",&n); while(n--){ vt.clear(); i=0; scanf("%s",x); while(x[i])vt.pb(x[i++]); sort(vt.begin(),vt.end()); it=m.insert(make_pair(vt,0)).first; printf("%d\n",it->second++); } //system("pause"); return 0; }