// Arup Guha
// 3/31/2013
// Solution to 2013 FHSPS Playoff Problem Baseball

import java.util.*;

public class baseball {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numSeasons = stdin.nextInt();

		// Go through each season.
		for (int loop=1; loop<=numSeasons; loop++) {

			int numPlayers = stdin.nextInt();
			player[] bigLeague = new player[numPlayers];

			// Read in each player for this season.
			for (int i=0; i<numPlayers; i++) {

				// Here is his name.
				String last = stdin.next();
				String first = stdin.next();

				// Now, go through each at bat.
				int plateAppearances = stdin.nextInt();
				code[] myCodes = new code[plateAppearances];
				for (int j=0; j<myCodes.length; j++)
					myCodes[j] = new code(stdin.next());

				// Now we can set up the player object.
				bigLeague[i] = new player(first, last, myCodes);
			}

			// Put in order of MVP.
			Arrays.sort(bigLeague);

			// Print out this order.
			System.out.println("Season #"+loop+":");
			for (int i=0; i<bigLeague.length; i++)
				System.out.println(bigLeague[i]);

			System.out.println();
		}
	}
}

class player implements Comparable<player> {

	final public static double EPSILON = 1e-9;

	private String last;
	private String first;
	private int atBats;
	private int hits;
	private int plateAppearances;
	private int totalBases;
	private int onBase;

	public player(String myFirst, String myLast, code[] season) {

		// Set up the name and plate appearances.
		first = myFirst;
		last = myLast;
		plateAppearances = season.length;

		// Update for each plate appearance.
		for (int i=0; i<season.length; i++) {

			// Check each of these stats and update if necessary.
			if (season[i].isHit())
				hits++;
			if (season[i].isOnBase())
				onBase++;
			if (season[i].isAtBat())
				atBats++;

			// Here we just add in the number of bases.
			totalBases += season[i].getNumBases();
		}
	}

	private double getBA() {
		return (double)hits/atBats;
	}

	private double getOBP() {
		return (double)onBase/plateAppearances;
	}

	private double getSlug() {
		return (double)totalBases/atBats;
	}

	public int compareTo(player other) {

		// Better player can be determined by batting average.
		if (this.getBA() - other.getBA() > EPSILON) return -1;
		if (this.getBA() - other.getBA() < -EPSILON) return 1;

		// Better player can be determined by on base percentage.
		if (this.getOBP() - other.getOBP() > EPSILON) return -1;
		if (this.getOBP() - other.getOBP() < -EPSILON) return 1;

		// Better player can be determined by slugging average.
		if (this.getSlug() - other.getSlug() > EPSILON) return -1;
		if (this.getSlug() - other.getSlug() < -EPSILON) return 1;

		// For this problem we should never get here, but we declare these
		// players to be tied!
		return 0;
	}

	public String toString() {
		return last+", "+first;
	}
}

class code {

	private boolean hit;
	private boolean atBat;
	private boolean onBase;
	private int numBases;

	public code(String myCode) {

		// First take care of the hits.
		if (myCode.equals("1B")) {
			hit = true;
			atBat = true;
			onBase = true;
			numBases = 1;
		}
		else if (myCode.equals("2B")) {
			hit = true;
			atBat = true;
			onBase = true;
			numBases = 2;
		}
		else if (myCode.equals("3B")) {
			hit = true;
			atBat = true;
			onBase = true;
			numBases = 3;
		}
		else if (myCode.equals("HR")) {
			hit = true;
			atBat = true;
			onBase = true;
			numBases = 4;
		}

		// For a walk, the only default that's wrong is onBase, since our
		// stats don't ever count this base.
		else if (myCode.equals("BB")) {
			onBase = true;
		}

		// Otherwise, it's still an at bat.
		else if (!myCode.equals("SAC")) {
			atBat = true;
		}

	}

	// Accessor methods.
	public boolean isHit() {
		return hit;
	}

	public boolean isOnBase() {
		return onBase;
	}

	public boolean isAtBat() {
		return atBat;
	}

	public int getNumBases() {
		return numBases;
	}
}