CF1900A.Cover in Water

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Cover in Water

Filip has a row of cells, some of which are blocked, and some are empty. He wants all empty cells to have water in them. He has two actions at his disposal:

  • 11 — place water in an empty cell.
  • 22 — remove water from a cell and place it in any other empty cell.

If at some moment cell ii (2in12 \le i \le n-1) is empty and both cells i1i-1 and i+1i+1 contains water, then it becomes filled with water.

Find the minimum number of times he needs to perform action 11 in order to fill all empty cells with water.

Note that you don't need to minimize the use of action 22. Note that blocked cells neither contain water nor can Filip place water in them.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1001 \le n \le 100) — the number of cells.

The next line contains a string ss of length nn. The ii-th character of ss is '.' if the cell ii is empty and '#' if cell ii is blocked.

Output

For each test case, output a single number — the minimal amount of actions 11 needed to fill all empty cells with water.

Note

Test Case 1

In the first test case, Filip can put water in cells 11 and 33. As cell 22 is between 22 cells with water, it gets filled with water too.

Test Case 2

In the second case, he can put water sources in cells 33 and 55. That results in cell 44 getting filled with water. Then he will remove water from cell 55 and place it into cell 66. As cell 55's neighbors, cell 44 and cell 66, have water in them, cell 55 also gets filled with water. You can see the illustration of this case below.

Operations in the second test case. White cells are empty, grey ones are blocked, and blue ones are water.

Test Case 3

In the third case, he can put water in all the empty cells. That requires 55 actions of type 11.

Test Case 4

In the fourth case, there are no empty cells. Therefore, he does not have to put any water in them.

Test Case 5

In the fifth test case, there exists a sequence of actions that requires only 22 type 11 actions.

Samples

5
3
...
7
##....#
7
..#.#..
4
####
10
#...#..#.#
2
2
5
0
2

在线编程 IDE

建议全屏模式获得最佳体验