#P3175. Awesome DJMAX

Awesome DJMAX

Problem Description


CD is an Otaku, he likes to play PSP game, and his favorite game is DJMAX. In this game, the player will listen to the music, then many notes will appear on the screen and fall down from the top. When the notes move to the line on the button of the screen, the player should press the correct keys just on time, and the system will judge your rate and give scores.
Every time after he finishes one mission, he always doubts the Score System of that game, he thinks he should get more points. Now he turns to you for help, can you write an impartial Score System so that tell him how many points he actually can get.
The rule of your Score System is:
a) There are three results CD may get: “COOL”, “GOOD”, “MISS”.
b) Each “COOL” will give CD 100 points; Each “GOOD” will give CD 50 points; Each “MISS” give CD 0 points.
c) Each “COOL” will give CD 1/10 “MAX-value”; Each “GOOD” will give CD 1/20 “MAX-value”. After CD gets one “MAX-value” or more, every “MAX-value” will add extra 10 scores to every “COOL” and 5 to every “GOOD”.
d) If CD beats notes incessantly, he will get COMBO. 2 notes will be 2 COMBO, 3 notes will be 3 COMBO, and so on. But, if he misses one note, the COMBO will back to zero, and all the “MAX-value” he have will be lost.

Input

The first line consists of an integer C(C<=50), indicating the number of test cases.
The first line of each case consists of an integers N(N<=1000), indicating the number of notes.
Then N lines follow, each line contains a string, this string will be “COOL”, “GOOD” or “MISS”.

Output

For each line, output an integer indicating the totals points CD gets.

1 20 COOL COOL COOL GOOD GOOD GOOD GOOD COOL COOL COOL COOL COOL COOL COOL MISS COOL MISS MISS GOOD COOL
1470