406754: GYM102535 K Kim Possible and the Mooks

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Kim Possible and the Mookstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Kim Possible has infiltrated Dr. Drakken's lair and has to fight off some MOOKS and MEEKS in order to stop him from his evil schemes.

However, much to Kim's surprise, Dr. Drakken knew Team Possible was coming for him as they always have. So he prepared a magical scientific device to strengthen his army of MOOKS and MEEKS.

All the MOOKS and MEEKS form a straight line and Kim Possible has to fight them starting from the first one. The MEEKS don't fight because they are tired, but the MOOKS take Kim one minute to defeat. Whenever Kim Possible defeats a MOOK, the MOOK will use his McGuffin which drains all of his energy and throws Kim Possible back to the start of the line. All the MEEKS in front of the MOOK get re-energized and turn back into MOOKS with their McGuffin fully recharged, but the MOOK that used his McGuffin turns into a MEEK, fully drained of energy.

Given the initial line of MOOKS and MEEKS, how many minutes will it take for Kim Possible to defeat all the MOOKS and turn them into MEEKS?

Input

The first line of input contains an integer $$$t$$$, the number of test cases. $$$t$$$ test cases follow.

The first line of each test case contains an integer $$$n$$$, the number of MOOKS/MEEKS. $$$n$$$ lines follow, each is either a MOOK or a MEEK, describing their order in their line.

Constraints

$$$1\leq t\leq 10^4$$$

$$$1\leq n\leq 50$$$

Output

For each test case, output a single integer which is the amount of time, in minutes, before Kim possible defeats all MOOKS.

ExampleInput
3
1
MOOK
3
MOOK
MEEK
MEEK
7
MOOK
MEEK
MEEK
MOOK
MEEK
MOOK
MEEK
Output
1
1
41

加入题单

上一题 下一题 算法标签: