import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<String> list = new ArrayList<>();
LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
while(sc.hasNextLine()) {
String in = sc.nextLine();
if(in.equals("")){
break;
};
String[] s = in.split(" ");
String[] s2 = s[0].split("\\\\");
int index=s2.length-1;
if(s2[index].length()>=16) {
String key1 = s2[index].substring(s2[index].length() - 16, s2[index].length());
list.add(key1);
}else{
String key1=s2[s2.length-1];
list.add(key1);
}
String key2 = s[1];
String key = list.get(0) + " " + key2;
list.remove(0);
if (!map.containsKey(key)) {
map.put(key, 1);
} else {
map.put(key, map.get(key) + 1);
}
}
ListIterator<Map.Entry<String,Integer>> it=null;
if((map.size()-8)>0){
it=new ArrayList<>(map.entrySet()).listIterator((map.size()-1)-7);
}else{
it=new ArrayList<>(map.entrySet()).listIterator();
}
int count=8;
while (it!=null&&it.hasNext()) {
Map.Entry<String, Integer> entry = it.next();
//stack.push(entry);
String k = entry.getKey();
Integer v = entry.getValue();
System.out.println(k+" "+v);
if(--count==0){
break;
}
}
}
}