const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    const map = {}
    while(line = await readline()){
        // 通过正则提取文件名及行号
        let strArr = line.match(/[\w\s]+$/).toString().split(" ")
        let fullName = strArr[0]
        let lineCode = strArr[1]
        fullName = fullName.substring(fullName.length-16)
        const key = fullName+" "+lineCode
        if(map[key]){
            map[key]++
        }else{
            map[key] = 1
        }
    }
    Object.keys(map).slice(-8).forEach(key=>console.log(key+" "+map[key]))
}()