#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
vector<pair<string, int>> ErrorN;
bool check(string s) {
    for (int i = 0; i < ErrorN.size(); i++) {
        if (ErrorN[i].first == s) {
            return false;
        }
    }
    return true;
}
bool cmp(pair<string, int> a,pair<string, int> b){
    return a.second>b.second;
}
int main() {
    string s;
    while (getline(cin, s)) {
        int idx_sp = s.rfind(' ');
        int idx_line = s.rfind('\\');
        if (idx_sp - idx_line > 17) {
            s = s.substr(idx_sp-16);
        }
        else{
            s=s.substr(idx_line+1);
        }
        if (check(s)) {
            pair<string, int> p(s, 1);
            ErrorN.push_back(p);
        } else {
            for (int i = 0; i < ErrorN.size(); i++) {
                if (ErrorN[i].first == s) {
                    ErrorN[i].second++;
                }
            }
        }
    }
    stable_sort(ErrorN.begin(),ErrorN.end(),cmp);
    for(int i=0;i<ErrorN.size()&&i<8;i++){
        cout<<ErrorN[i].first<<" "<<ErrorN[i].second<<endl;
    }
}
// 64 位输出请用 printf("%lld")