#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;

int main() {
	
  ifstream file; // A in file stream, the c++ way of reading files. 
    //file.open ("example.txt");
    string word; // A word to store each word. 
    std::map<std::string, int> myWords;
    
    // Read each word. 
    while ( cin >> word) {
         if (myWords.find(word) == myWords.end()) {
        myWords[word] = 1;
    } else {
        myWords[word]++;
    } 
    }
    
       for (auto wordPair : myWords) {
        std::cout << wordPair.first << " " << wordPair.second <<  std::endl;
    }
    
	// your code goes here
	return 0;
}