// Arup Guha
// 2/10/2017
// Solution to 2017 FHSPS Playoff Problem: High Score

import java.util.*;

public class highscore {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			int n = stdin.nextInt();
			score[] list = new score[n];

			// Read in each of the n players.
			for (int i=0; i<n; i++) {

				// Get the name and level.
				String name = stdin.next();
				int levels = stdin.nextInt();
				int[] scoreList = new int[levels];

				// Now get all of this player's scores.
				for (int j=0; j<levels; j++)
					scoreList[j] = stdin.nextInt();

				// Finally, create the object.
				list[i] = new score(name, scoreList);
			}

			// Now, sort it!
			Arrays.sort(list);

			// Print sorted list.
			System.out.println("Game #"+loop);
			for (int i=0; i<list.length; i++)
				System.out.println(list[i]);
		}
	}
}

class score implements Comparable<score> {

	public String ID;
	public int levels;
	public int[] scores;
	public int total;

	// Create the object.
	public score(String name, int[] list) {
		ID = name;
		levels = list.length;
		scores = list;
		total = 0;
		for (int i=0; i<list.length; i++)
			total += list[i];
	}

	public int compareTo(score other) {

		// First differentiator.
		if (this.levels != other.levels)
			return other.levels - this.levels;

		// Next is total score.
		if (this.total != other.total)
			return other.total - this.total;

		// Now, find the first level there is a discrepancy!
		for (int i=0; i<levels; i++)
			if (this.scores[i] != other.scores[i])
				return other.scores[i] - this.scores[i];

		// Otherwise, by name, alpha.
		return this.ID.compareTo(other.ID);
	}

	public String toString() {
		return ID;
	}
}