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.hasNextLine()) {
            String line = sc.nextLine();
            String[] split = line.split(" ");
            String path = split[0];
            int lineNumber = Integer.parseInt(split[1]);
            String fileName = path.substring(path.lastIndexOf("\\") + 1);
            if (fileName.length() > 16) {
                fileName = fileName.substring(fileName.length() - 16);
            }
            String key = fileName + " " + lineNumber;
            map.put(key, map.getOrDefault(key, 0) + 1);
        }
        sc.close();
        List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
        int size = list.size();
        int start = size > 8 ? size - 8 : 0;
        for (int i = start; i < size; i++) {
            Map.Entry<String, Integer> entry = list.get(i);
            System.out.println(entry.getKey() + " " + entry.getValue());

        }
    }
}