import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

// 参考了:https://blog.nowcoder.net/n/6eb9f37c83e94cf89df0c97bc7398355?f=comment
public class Main {
    public static void main(String[] args) {
        Map<String, Integer> map = new LinkedHashMap<>();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String inputLine = scanner.nextLine();
            if (inputLine == null || inputLine.trim().length() == 0) {
                scanner.close();
                break;
            }
            // 1.分割内容与行号
            String[] firstArr = inputLine.split(" ");
            String fname = firstArr[0].substring(firstArr[0].lastIndexOf("\\") + 1);
            fname = fname.substring(Math.max(fname.length() - 16, 0)) + " " + firstArr[1];
            // 2.向map中存数据
            int value = map.get(fname) == null ? 1 : map.get(fname) + 1;
            map.put(fname, value);
        }

        // 输出后8个
        int count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (map.size() - count <= 8) {
                System.out.println(entry.getKey() + " " + entry.getValue());
            }
            ++count;
        }

    }
}