// Arup Guha
// 12/10/2009
// Example of using the Comparable interface for AP Computer Science

import java.io.*;
import java.util.*;

public class FootballPlayer implements Comparable<FootballPlayer> {
	
	// Components of a football player.
	private String name;
	private String position;
	private int powerRanking;
	
	// Creates a Football player object with all the necessary statistics.
	public FootballPlayer(String n, String p, int pass, int rush, int rec, int TD) {
		name = n;
		position = p;
		powerRanking = pass/30 + (rush+rec)/10 + 6*TD;
	}
	
	// Here is how we want a player to print out.
	public String toString() {
		return name + " " + position + " " + powerRanking;
	}
	
	public int compareTo(FootballPlayer other) {
		
		// First sort by power ranking.
		if (this.powerRanking != other.powerRanking)
			return other.powerRanking - this.powerRanking;
		
		// Break ties by name.
		return this.name.compareTo(other.name);
		
	}
	
	public static void main(String[] args) throws Exception {
		
		// Open file.
		Scanner stdin = new Scanner(System.in):
		System.out.println("What is the name of your input file?");
		String fileName = stdin.next();
		Scanner fin = new Scanner(new File(fileName));
		
		ArrayList<FootballPlayer> nfl = new ArrayList<FootballPlayer>();
		
		int numPlayers = fin.nextInt();
		
		// Go through the file.
		for (int i=0; i<numPlayers; i++) {
			
			// Get this player's stats.
			String name = fin.next();
			String position = fin.next();
			int pass = fin.nextInt();
			int rush = fin.nextInt();
			int rec = fin.nextInt();
			int TDs = fin.nextInt();
			
			// Add this guy to our list!
			FootballPlayer tmp = new FootballPlayer(name,position,pass,rush,rec,TDs);
			nfl.add(tmp);
		}
		
		// Sort and print.
		Collections.sort(nfl);
		
		for (int i=0; i<nfl.size(); i++)
			System.out.println(nfl.get(i));
			
		fin.close();
	}
}
