import java.util.*;
public class Main {
// 存储文件记录
public static Map<String, Integer> map = new LinkedHashMap<>();
public static void main(String[] args) {
// 标准输入
Scanner input = new Scanner(System.in);
// 循环获取输入记录
while (input.hasNext()) {
String file = input.next();
int lineCount = input.nextInt();
// 根据 '\'切分后获取文件名
String[] fileSeg = file.split("\\\\");
String fileName = fileSeg[fileSeg.length-1];
// 只保留文件名的最后16位
if (fileName.length() > 16) {
fileName = fileName.substring(fileName.length()-16);
}
// 拼接待存入记录的key值
String key = fileName + " " + lineCount;
// 添加记录到结果集
map.put(key, map.getOrDefault(key,0) + 1);
}
// 统计完毕,输出统计结果
int count = 0;
for (String key : map.keySet()) {
count++;
// 输出最后8个记录
if ( count > (map.keySet().size()-8) ) {
System.out.println(key + " " + map.get(key));
}
}
}
}