Subodh is going to paint a very big wall. The wall is composed of adjacent parts in line. He wants to paint each part with a particular color. He paints in a somewhat peculiar mechanism. At each step he chooses some consecutive parts of the wall and paints them with same color. Initially, there is no color on any part of the wall. You’re given the target color for each part of the wall. You have to tell the minimum number of steps Subodh will require if he wants to paint the whole wall in the desired color combination using his peculiar approach.
First line of input will contain (), the number of test cases. First line of each test case will contain () number of parts in the wall and then follows N numbers on the next line. The -th () number () represents the required color on the -th part of the wall.
For each test case provide the minimum number of required steps.
Input | Output |
---|---|
2 5 1 1 2 2 2 3 1 2 1 | 2 2 |
For the first case, he can choose the first two parts in step one and paint them with color 1 and in second step, choose the remaining three parts and paint them with color 2. For the second case, he can paint the whole wall with color 1 in first step and then paint second part with color 2 in second step. |