#include <cstdlib>
#include <iostream>
#include <map>
#include <string>

using namespace std;

typedef map<string,int> hash;
typedef hash::const_iterator iter;

int main()
{
  hash score;
  string word;

  ios::sync_with_stdio(false);

  while (cin >> word)
    score[word]++;

  for (iter p = score.begin(); p != score.end(); p++)
    cout << p->first <<  ' ' << p->second << '\n';

  exit(0);
}

