#include <iostream>
#include<unordered_map>
#include<string>
#include<deque>
using namespace std;
int main() {
string s;
unordered_map<string, int>mp;
deque<string>dq;
while (getline(cin, s)) {
int pos, end = 0;
string str = s.substr(s.find_last_of('\\') + 1);
pos = str.find_last_of(' ');
if (pos > 16) {
str = str.substr(pos - 16);
}
if (mp.find(str) == mp.end())dq.push_back(str);
++mp[str];//if语句后不加花括号{}时,仅会执行紧随其后的第一条语句。
//如果`str`不在map中:1. mp[str]会插入`str`,并将其值初始化为`0`;2. 然后`++`操作将该值增加为`1`。
//如果`str`已经在map中:直接将其值加1。
if (dq.size() > 8)dq.pop_front();
}
for (auto i : dq) {
cout << i << " " << mp[i] << endl;
}
}
// 64 位输出请用 printf("%lld")