#include <map>
#include <iostream>
#include <string>
using namespace std;

/* Program tworzy slownik wyrazow pojawiajacych sie na standardowym wejsciu.
 * Aby przerwac wczytywanie i wyswietlic rezultat wcisnij Ctrl+Z (w konsoli Windows) lub Ctrl+D (w konsoli Linux).
 * */

int main()
{
   string w;

	// Tworzymy slownik
	map<string,int> slownik;
	while(cin >> w) slownik[w]++;

	//Wyswietlamy slownik
	map<string,int>::iterator it;
	for(it=slownik.begin(); it!=slownik.end(); it++)
   {
		cout << it->first << " " <<  it->second << endl;
   }

	return 0;
}
