import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Map<String,Integer> map = new LinkedHashMap<>();
while (sc.hasNext()){
String msg = sc.nextLine();
String[] s = msg.split(" ");
String[] split = s[0].split("\\\\");
String fileName = split[split.length-1];
String realName;
if (fileName.length()>=16){
realName = fileName.substring(fileName.length()-16)+" "+s[1];
}else{
realName = fileName+" "+s[1];
}
if (map.containsKey(realName)){
map.put(realName,map.get(realName)+1);
}else{
map.put(realName,1);
}
}
Set<String> strings = map.keySet();
if(map.size()<=8){
for (String s : strings) {
System.out.println(s+" "+map.get(s));
}
}else{
List<String> list = new ArrayList<>(strings);
for (int i = list.size()-8;i < list.size();i++){
System.out.println(list.get(i) + " " + map.get(list.get(i)));
}
}
}
}