// Josh Linge
// 2/21/2017
// Solution to 2017 FHSPS Playoff Question: High Score

import java.util.Arrays;
import java.util.Scanner;

public class highscore_linge {

  public static void main(String[] args) {
  	
    Scanner in = new Scanner(System.in);
    int t = in.nextInt();
    
    // Process cases.
    for(int cur = 1; cur <= t; ++cur) {
    	
      int n = in.nextInt();
      Player[] players = new Player[n];
    
      // Read in each player and store.  
      for(int i = 0; i < n; ++i) {
        String name = in.next();
        int s = in.nextInt();
        int[] scores = new int[s];
        
        for(int j = 0; j < s; ++j) {
          scores[j] = in.nextInt();
        }
        players[i] = new Player(name, scores);
      }
      
      // Sort and output in order.
      Arrays.sort(players);
      System.out.println("Game #"+cur);
      for(Player p : players) {
        System.out.println(p.name);
      }
    }
    
    in.close();
  }

  // Object for custom sorting.
  static class Player implements Comparable<Player> {
    
    String name;
    int total = 0;
    int[] scores;
    
    // Basic constructor, also add up scores.
    Player(String n, int[] s) {
      name = n;
      scores = s;
      
      for(int i : scores) {
        total += i;
      }
    }
    
    // How to compare two objects.
    public int compareTo(Player p) {
    	
      // First criterion.
      int ret = p.scores.length - scores.length;
      
      // Need to move to a tiebreaker of total points.
      if(ret == 0) {
        ret = p.total - total;
      }
      
      // Now tiebreaker based on levels.
      if(ret == 0) {
        for(int i = 0; i < scores.length && ret == 0; ++i) {
          ret = p.scores[i] - scores[i];
        }
      }
      
      // Finally based on names.
      if(ret == 0) {
        ret = name.compareTo(p.name);
      }
      
      // Now we are done.
      return ret;
    }
  }
}
