#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;
int main() {
string path_name;
int error_row;
unordered_map<string, int> u_map;
vector<string> orginal_order;
vector<pair<string ,int>> pair_order;
while (cin >> path_name >> error_row) { // 注意 while 处理多个 case
stringstream ss(path_name);
string segment;
vector<string> parts;
while (getline(ss, segment, '\\')) if (!segment.empty()) parts.push_back(segment);
string filename ;
if (!parts.empty()) filename = parts.back();
// cout<<filename<<endl;
// auto temp_pair = make_pair(filename, error_row);
string temp_error = filename +"\\" +to_string(error_row);
// cout<<temp_error<<endl;
if (u_map.count(temp_error) != 0) {
u_map[temp_error]++;
} else {
u_map[temp_error] = 1;
orginal_order.push_back(temp_error);
}
}
pair_order.reserve(orginal_order.size());
for(const auto& tem_error:orginal_order) {
// cout<<tem_error<<endl;
pair_order.emplace_back(tem_error,u_map[tem_error]);
}
// cout<<"u_map.size():"<<u_map.size()<<" orginal_order.size():"<<orginal_order.size()<<" pair_order.size():"<<pair_order.size()<<endl;
// for(const auto& [key,val]:u_map){
// cout<<key<<val<<endl;
// }
// for(const auto& te_error:orginal_order){
// cout<<te_error<<endl;
// }
// for(const auto& te_error_pair:pair_order){
// cout<<te_error_pair.first<<te_error_pair.second<<endl;
// }
auto cmp = [](pair<string,int> a,pair<string,int> b){return a.second>b.second;};//a>b,a的优先级低,排在前面,所以是降序,结合原序可以实现先出现的在前
stable_sort(pair_order.begin(),pair_order.end(),cmp);
// for(const auto& te_error_pair:pair_order){
// cout<<te_error_pair.first<<te_error_pair.second<<endl;
// }
int num = pair_order.size()>8 ? 8: pair_order.size();
for(int i=0;i<num;i++){
pair<string,int> max_tp = pair_order[i];
stringstream st1(max_tp.first);
string part;
while(getline(st1, part,'\\')){
if(!part.empty()) {
string cout_str;
cout_str = part.size()>16? part.substr(part.size()-16):part;
cout<<cout_str<<" ";
}
}
cout<<max_tp.second<<endl;
}
}
// 64 位输出请用 printf("%lld")