// Arup Guha
// 1/25/2010
// Solution to my made up contest problem: Scores

import java.io.*;
import java.util.*;

public class scores implements Comparable<scores> {

	// Part of our object.	
	public String name;
	public int points;
	
	public scores(String n, int p) {
		name = n;
		points = p;
	}
	
	// This is how we compare them.
	public int compareTo(scores other) {
		if (this.points > other.points)
			return -1;
		if (this.points < other.points)
			return 1;
		return this.name.compareTo(other.name);
	}
	
	// Their output spec just prints this...
	public String toString() {
		return name;
	}
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		// Since we don't know how many, use this.
		ArrayList<scores> all = new ArrayList<scores>();
		
		// Add each item to the array list.
		while (stdin.hasNext()) {
			
			// Read in a whole line and set up the string tokenizer.
			String line = stdin.nextLine();
			StringTokenizer tok = new StringTokenizer(line);
			
			// Extract the name
			String name = tok.nextToken();
			
			int sum = 0;
			
			// Keep on looping until all the tokens are gone. 
			// Note: The method countTokens() returns how many tokens are currently
			//       left to extract from the StringTokenizer object.
			while (tok.hasMoreTokens()) {
				
				// We retrieve the number by first getting it as a String, and then
				// converting the string to an int using the method Integer.parseInt.
				// If we needed to convert to a double, it's Double.parseDouble(...)
				int nextNum = Integer.parseInt(tok.nextToken());
				sum += nextNum;
			}
			all.add(new scores(name,sum));	
		}
		
		// Sort and print =)
		Collections.sort(all);
		
		for (int i=0; i<all.size(); i++) 
			System.out.println(all.get(i));
	}
}