// I have failed to find a definition for the standard hash function for
// the string class in the gxx include files, so I had to write my own.

#include <cstdlib>
#include <algorithm>
#include <ext/hash_map>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using __gnu_cxx::hash_map;

namespace __gnu_cxx {
  template<> struct hash<string>
  {
    size_t operator()(const string &s) const
    { return __stl_hash_string(s.c_str()); }
  };
}

typedef hash_map<string,int> hash;
typedef hash::const_iterator hash_iter;
typedef vector<string> list;
typedef list::const_iterator list_iter;

int main()
{
  hash score(100003);
  list words;
  string word;

  ios::sync_with_stdio(false);

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

  for (hash_iter p = score.begin(); p != score.end(); p++)
    words.push_back(p->first);

  sort(words.begin(), words.end());

  for (list_iter p = words.begin(); p != words.end(); p++)
    cout << *p << ' ' << score[*p] << '\n';

  exit(0);
}
