const length = parseInt( readline() )

const map = {}

for( let i = 0; i < length; i++ ) {
    
    const [ key, value ] = readline().split(" ").map(Number)
    
    if( map[key] ) {
        map[key] += value
    }else {
        map[key] = value
    }

}

Object.keys(map).forEach( key => {
    print(`${key} ${map[key]}`)
})