#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  string x,y;
  map<string,int> mp;
  cin>>a;
  b=a;
  while(b--)
  {cin>>x;
   mp[x]++;
  }
  for(auto i:mp)
    cout<<i->first<<" * "<<i->second<<endl;
  return 0;
