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

int main()
{
    std::map<std::string, int> dictionary;
    std::string input;
    while(std::cin >> input && input != "**END**")
        ++dictionary[input];
    for(const auto& e: dictionary)
        if(e.second > 1)
            std::cout << e.first << ' ' << e.second << '\n';
}
