{"raw_statement":[{"iden":"statement","content":"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.\n\nHowever, 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.\n\nAll 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.\n\nGiven 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?\n\nThe first line of input contains an integer $t$, the number of test cases. $t$ test cases follow.\n\nThe 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.\n\n*Constraints*\n\n$1 <= t <= 10^4$\n\n$1 <= n <= 50$\n\nFor each test case, output a single integer which is the amount of time, in minutes, before Kim possible defeats all MOOKS.\n\n"},{"iden":"input","content":"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 <= t <= 10^4$$1 <= n <= 50$"},{"iden":"output","content":"For each test case, output a single integer which is the amount of time, in minutes, before Kim possible defeats all MOOKS."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of people.  \nLet $ W = (w_1, w_2, \\dots, w_n) \\in \\mathbb{Z}^n $ be the sequence of weights.  \nLet $ H = (h_1, h_2, \\dots, h_n) \\in \\mathbb{Z}^n $ be the sequence of heights, with all $ h_i $ distinct.\n\n**Constraints**  \n- $ n \\geq 1 $  \n- All $ h_i $ are distinct.\n\n**Objective**  \nLet $ \\sigma $ be the permutation of $ \\{1, 2, \\dots, n\\} $ such that $ h_{\\sigma(1)} < h_{\\sigma(2)} < \\dots < h_{\\sigma(n)} $.  \nOutput the sequence $ (w_{\\sigma(1)}, w_{\\sigma(2)}, \\dots, w_{\\sigma(n)}) $.","simple_statement":"Sort the weights by height in ascending order and output the weights in that order.","has_page_source":false}