#include <iostream>
#include <map>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
int main() {
string str;
int line;
map<pair<string, int>, int> umap;
vector<pair<string, int>> order;
while(cin >> str >> line) {
string token;
stringstream ss(str);
while (getline(ss, token, '\\')); //两个反斜杠才表示用一个反斜杠作为分隔符 注意反斜杠的特殊性
int n = token.size();
if(n > 16) {
token = token.substr(n-16, 16);
}
pair<string, int> key = {token, line};
if(umap.find(key) == umap.end()) {
order.push_back(key);
}
++umap[key];
if(order.size() > 8) {
order.erase(order.begin());
}
}
for(const auto& it: order) {
cout << it.first << " " << it.second << " " << umap[it] << endl;
}
return 0;
}