#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
string getFileName(string path)
{
int nPos = path.find_last_of('\\') + 1;
string fileName = path.substr(nPos, path.length()-nPos);
if (fileName.length() > 16) {
fileName = fileName.substr(fileName.length()-16, 16);
}
return fileName;
}
string toNewInfo(string info) {
stringstream ss(info);
string newInfo;
for (int i=0; i<2; i++) {
string a;
if (getline(ss, a, ' ')) {
if (0 == i) {
newInfo = getFileName(a);
} else {
newInfo += " ";
newInfo += a;
}
}
}
return newInfo;
}
int main() {
string a;
map<string, int> logMap;
vector<string> logVec;
map<string, int>::iterator iter;
while (getline(cin, a)) {
string log = toNewInfo(a);
iter = logMap.find(log);
if (iter != logMap.end()) {
iter->second += 1;
} else {
logMap.insert(make_pair(log, 1));
logVec.push_back(log);
}
}
while (logVec.size() > 8) {
logVec.erase(logVec.begin());
}
for (auto log: logVec) {
iter = logMap.find(log);
cout << log << " " << iter->second << endl;
}
}
// 64 位输出请用 printf("%lld")