/* Chris Poon
   Solution to 'Booling' in BHCSI Programming Contest '04.

*/

import java.io.*;

public class booling{

	public static void main(String args[]) throws IOException{
		int[] facts=new int[7]; 
		facts[0]=1;			//hard coded factorial values
		facts[1]=1;			// to save computation time.
		facts[2]=2;			//Not really that significant
		facts[3]=6;			// in this problem, but it's
		facts[4]=24;			// always a good idea to save
		facts[5]=120;			// performance in most contest
		facts[6]=720;			// problems.
		

		int numplayers;
		int score;			//various counters, etc.
		int numgames;
		int foulcount;
		char result;

		BufferedReader infile=new BufferedReader(new FileReader("Booling.in"));
		numgames=Integer.parseInt(infile.readLine());

		for (int x=1;x<=numgames; x++){
			//main outer loop for processing each game.

			System.out.println("Game #" + x + ":");
			numplayers=Integer.parseInt(infile.readLine());
			for (int p=1; p<=numplayers; p++){
				//loop for each player.

				score=0;	//reset for each player.
				foulcount=0;	
				for (int frame=1; frame<=6; frame++){
					//loop that reads in the 6 frames,
					// computes the score, and outputs
					// it and end since each player's
					// score is independent and doesnt
					// need to be saved.

					result=(infile.readLine()).charAt(0);
					if (Character.isDigit(result)){
						score+=facts[((int) result-'0')];
					}
					else if (result=='X'){
						if (score<facts[6]){
							score+=facts[6];
						}
						else{
							score+=score;
						}
					}
					else { //meaning it must be a foul.
						score-= (350* (++foulcount));
					}
				}

				//decide which output.
				if (score>=0)
					System.out.println(" Player "+p+" scores "+score+".");
				else
					System.out.println(" Player "+p+" needs new underwear.");
			}
			System.out.println(""); //can't forget about that space between games.
		}



		
		
		
	}
}