let arr = []
while(line = readline()) {
arr.push(line);
}
const length = arr[0];
let list = arr.slice(1, length + 1);
let newArr = [];
for (item of list) {
let key = parseInt(item.split(' ')[0]);
let value = parseInt(item.split(' ')[1]);
newArr[key] = newArr[key] ? newArr[key] + value : value;
}
for (key in newArr) {
if (newArr[key]) {
print(key + ' ' + newArr[key]);
}
}