#include <deque>
#include<iostream>
#include <map>

using namespace std;
int main(){
    string str;
    map<string, int> mymap;
    deque<string> deq;
    while(getline(cin, str)){
	  // 首先解析字符串
        int pos = str.find_last_of('\\');
        str = str.substr(pos+1);
        pos = str.find_last_of(' ');
        if(pos > 16){
            str = str.substr(pos-16);
        }
		// 把数据存放在双端队列中
        if(mymap.find(str) == mymap.end()){
            deq.push_back(str);
        }
		// 维持双端队列中只有八条数据。
        if(deq.size() > 8){
            deq.pop_front();
        }
        mymap[str]++;

    }

    for(auto s : deq){
        cout << s << " " << mymap[s] << endl;
    }
    return 0;
}