var line='' var arr=[] var res=[]

while(line=readline()){ arr.push(line) }

var firs=arr.splice(0,1)

for(let i=0;i<firs;i++){ var index=parseInt(arr[i].split(' ')[0])

var value=parseInt(arr[i].split(' ')[1])
res[index]=res[index]? res[index]+value : value

} for (key in res) { if (res[key]) { print(key + ' ' + res[key]); } }