public class Solution {
    public static void main(String[] args) throws IOException {
        String filename = args[0];
        Map<String, Double> map = new TreeMap<>();
        BufferedReader reader = new BufferedReader(new FileReader(filename));
        while (reader.ready()) {
            String[] x = reader.readLine().split(" ");
            if(map.size()==0||!map.containsKey(x[0]))
                map.put(x[0],new Double(x[1]));
            else {
                for(Map.Entry<String,Double> pair: map.entrySet()){
                    if(pair.getKey().equals(x[0]))
                        map.replace(x[0],pair.getValue(),pair.getValue().doubleValue()+Double.parseDouble(x[1]));
                }

            }
        }
        reader.close();

        for (Map.Entry<String, Double> pair : map.entrySet()) {
            System.out.println(pair.getKey() + " " + pair.getValue());
        }
    }
}