#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
struct record{
string name;
int col;
int count;
};
int main() {
string recs;
int col;
int cnt=0;
record Rec[100];
while(cin>>recs>>col){
int pos= recs.find_last_of('\\');
string rec=recs.substr(pos+1);
record r;
string str;
if(rec.size()>16){
str=rec.substr(rec.size()-16);
}else str=rec;
// cout<<str<<"|| "<<col<<endl;
int flag=0;
for(int i=0;i<cnt;i++){
if(str==Rec[i].name && Rec[i].col==col){
flag=1;
Rec[i].count++;
break;
}
}
if(!flag){
r.name=str;
r.col=col;
r.count=1;
Rec[cnt]=r;
cnt++;
}
}
if(cnt>8){
for(int i=cnt-8;i<cnt;i++){
cout<<Rec[i].name<<" "<<Rec[i].col<<" "<<Rec[i].count<<endl;
}
}else {
for(int i=0;i<cnt;i++){
cout<<Rec[i].name<<" "<<Rec[i].col<<" "<<Rec[i].count<<endl;
}
}
return 0;
}
// 64 位输出请用 printf("%lld")