Malvika gets bored along with her Cats
Time limit1sMemory limit1024 MB
Given bar lengths in a row, find the fewest picks needed to eat every bar, where each pick also eats all bars forming an inversion with the picked bar.
Problem
Malvika's cats, Chingam and Jimma, are also bored of solving problems. Fortunately, Chingam has found dark chocolate bars. They all have the same width but differ in length, and no two bars have the same length. The bars are kept in a row, with lengths from left to right. That is, bar has length .
Chingam decided to play a small game with Jimma. In one step, Jimma chooses a bar that has not been eaten yet. Chingam hates inversions, so he instantly eats that bar, along with every other bar that forms an inversion pair with it. Bars and form an inversion pair when the bar on the left is longer than the bar on the right.
So if Jimma selects bar , Chingam eats bar , every bar with and , and every bar with and . Then the step ends, and the next step begins with Jimma selecting another bar. The process repeats until all bars are eaten.
Jimma does not like this game because she gets no chocolate. So she wants to finish it as soon as possible and go back to sleep. Find the minimum number of steps needed for the game to end.
Input
The first line contains a single integer , the number of test cases.
The first line of each test case contains one integer .
The second line contains space-separated integers .
Output
For each test case, output a single integer on its own line: the minimum number of steps needed for the game to end.
Constraints
Hint
In the first step, Jimma can choose bar 4, which has length 2. Bars 3 and 1 form inversion pairs with bar 4, so Chingam eats all three bars. In the second step, Jimma chooses bar 2, and the game ends. You can check that Jimma cannot remove all four bars in one step.