#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main (){
    vector<string> log;
    vector<int> num(101);
    int i = 0;
    string str;
    while(getline(cin, str)){
        string log1;
        int n1 = str.find_last_of('\\'), n2 = str.find_first_of(' ');
        log1 = (n2 - n1) > 16 ? str.substr(n2-16) : str.substr(n1+1);
        vector<string>::iterator it = find(log.begin(), log.end(), log1);
        if(it == log.end()){
            log.push_back(log1);
            num[i++] = 1;
        }
        else
            num[distance(log.begin(), it)]++;
    }
    for(int i = log.size() > 8 ? log.size() - 8 : 0; i < log.size(); ++i){
        cout << log[i] << ' ' << num[i] << endl;
    }
}