public class Solution {
    public static void main(String[] args) throws IOException {
        ArrayList<String> lastName = new ArrayList<>();
        TreeMap<String, Double> human = new TreeMap<>();
        Double max = Double.MIN_VALUE;
        Double current = 0.0;
        Double old = 0.0;
        String name = "";
        BufferedReader reader = new BufferedReader(new FileReader(args[0]));
        while (reader.ready()) {
            String[] data = reader.readLine().split(" ");
            current = Double.parseDouble(data[1]);
            if (human.containsKey(data[0])) {
                old = human.get(data[0]);
                human.put(data[0], old + current);
            } else {
                human.put(data[0], Double.parseDouble(data[1]));
            }
        }
        for (Map.Entry<String, Double> pair : human.entrySet()) {
            if (pair.getValue() >= max) {
                max = pair.getValue();
                name = pair.getKey();
                lastName.add(name);
            }
        }
        Collections.sort(lastName);
        for (String output : lastName) {
            System.out.println(output);
        }
        reader.close();
    }
}