#include <iostream>
#include <sstream>
#include <map>
#include <queue>

using namespace std;

int main() {
    int i = 0, j;
    string line, tmp;
    map<string, int> m; // [string, count]
    queue<string> q;

    while(getline(cin, line)) {
        stringstream ss(line);
        while(getline(ss, tmp, '\\'));  // 取最后一部分
        j = tmp.find(' ');
        j = j > 16 ? j - 16 : 0;
        tmp = tmp.substr(j);

        if (m.count(tmp)) { // 之前出现过
            m[tmp] += 1;
        } else {
            m[tmp] += 1;
            q.push(tmp);
            if (q.size() > 8) q.pop();
        }
    }

    while(!q.empty()) {
        tmp = q.front();
        q.pop();
        cout << tmp << " " << m[tmp] << endl;
    }
}