import java.util.Scanner;

import java.util.TreeMap;
public class Main {
    public static void main(String[] args) {
    Scanner sc  = new Scanner(System.in);
    int n = sc.nextInt();
    TreeMap<Integer,Integer>map = new TreeMap<>();
    for(int i = 0;i<n;i++){
        int index = sc.nextInt();
        int value = sc.nextInt();
        map.put(index,map.getOrDefault(index,0)+value);
    }
    for(Integer key : map.keySet()){
        System.out.println(key+" "+map.get(key));
    }
    }
}