#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <queue>
using namespace std;
string get_filename(string& filepath) { //题取文件名
string res = "";
for (int i = filepath.length() - 1; i >= 0; i--) { //逆向查找到第一个斜杠
if (filepath[i] == '\\')
break;
res = filepath[i] + res; //将字符加到字符串前面
}
if (res.length() > 16) //长度大于16的时候,截取后16位
res = res.substr(res.length() - 16, 16);
return res;
}
int main() {
map<pair<string, int>, int> filestore;
string filepath;
int line, num = 0;
queue<pair<string, int>> q;
while (cin >> filepath >> line) {
string file_name = get_filename(filepath);
pair<string, int> e = make_pair(file_name, line);
if (!filestore.count(e)) {
q.emplace(e);
++num;
}
++filestore[e];
if (num > 8) {
q.pop();
--num;
}
}
for (int i = 0; i < 8; ++i) {
if (!q.empty()) {
pair<string, int> front_e = q.front();
q.pop();
int cx = filestore[front_e];
cout << front_e.first << ' ' << front_e.second << ' ' << cx << endl;
} else {
break;
}
}
return 0;
}