/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
 *
 * @author amy hoover
 */

class Robot implements Comparable<Robot> {
	
    int time;
    int id;
    int score;
    static boolean compareById = false;

    public Robot(int time, int id)
    {
        this.time = time;
        this.id = id;
        this.score = 0;
    }

    // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    public int compareTo(Robot o)
    {
        if(!compareById)
        {
            if(this.time < o.time)
            {
                return -1;
            }
            else if (this.time == o.time)
            {
                return 0;
            }
            else
                return 1;
        }
        else
        {
            if(this.id < o.id)
            {
                return -1;
            }
            else if (this.id == o.id)
            {
                return 0;
            }
            else
                return 1;
        }
    }

}

public class robocode {

    //Stores Robots for the test case.
    ArrayList<Robot> robotList = new ArrayList<Robot>();

    public static void main(String[] args) throws Exception
    {
    	Scanner fin = new Scanner(new File("robocode.in"));
    	int numCases = fin.nextInt();

    	for (int i=1; i<= numCases; i++) {

    		// Output header
    		System.out.println("RoboCode Battle #"+i+":");

        	robocode rbBon = new robocode();
        	rbBon.populateRobotList(fin);
        	rbBon.calculateRobotBonus();
        	rbBon.printRobotList();
    	}
    }

    //Populates the robotList with robot data
    public void populateRobotList(Scanner sin)
    {
        //Read in and add all robots for this case.
        int robotCount = sin.nextInt();
        for(int i = 0; i < robotCount; i++)
        {
            robotList.add(new Robot(sin.nextInt(), i));
        }
    }

    //Calculates the bonuses for each robot
    public void calculateRobotBonus()
    {
        //Sort the robotList scores in ascending order
        Robot.compareById = false;
        Collections.sort(robotList);

        //Gives 50 points to every robot that stays alive while another dies
        for(int i = 0; i < robotList.size(); i++)
        {
             robotList.get(i).score += 50 * i;

             // Survivor bonus
             if(i + 1 == robotList.size())
             {
                 robotList.get(i).score += 10 * (robotList.size()-1);
             }
        }

        //Hacky way to resort by ID
        Robot.compareById = true;
        Collections.sort(robotList);
    }

    public void printRobotList()
    {
       int maxScore = -1;
       int maxScoreId = -1;

       Robot.compareById = true;
       Collections.sort(robotList);

       for(int i = 0; i < robotList.size(); i++)
       {
            System.out.println("The robot dead in " + robotList.get(i).time + " seconds received "+ robotList.get(i).score + " bonus points.");
            if(maxScore < robotList.get(i).score)
            {
                maxScore = robotList.get(i).score;
                maxScoreId = i;
            }
        }

        System.out.println();
    }


}
