#P1437B. Reverse Binary Strings

    ID: 1103 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>constructive algorithmsgreedy*1200

Reverse Binary Strings

No submission language available for this problem.

Description

You are given a string ss of even length nn. String ss is binary, in other words, consists only of 0's and 1's.

String ss has exactly n2\frac{n}{2} zeroes and n2\frac{n}{2} ones (nn is even).

In one operation you can reverse any substring of ss. A substring of a string is a contiguous subsequence of that string.

What is the minimum number of operations you need to make string ss alternating? A string is alternating if sisi+1s_i \neq s_{i + 1} for all ii. There are two types of alternating strings in general: 01010101... or 10101010...

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases.

The first line of each test case contains a single integer nn (2n1052 \le n \le 10^5; nn is even) — the length of string ss.

The second line of each test case contains a binary string ss of length nn (sis_i \in {0, 1}). String ss has exactly n2\frac{n}{2} zeroes and n2\frac{n}{2} ones.

It's guaranteed that the total sum of nn over test cases doesn't exceed 10510^5.

For each test case, print the minimum number of operations to make ss alternating.

Input

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases.

The first line of each test case contains a single integer nn (2n1052 \le n \le 10^5; nn is even) — the length of string ss.

The second line of each test case contains a binary string ss of length nn (sis_i \in {0, 1}). String ss has exactly n2\frac{n}{2} zeroes and n2\frac{n}{2} ones.

It's guaranteed that the total sum of nn over test cases doesn't exceed 10510^5.

Output

For each test case, print the minimum number of operations to make ss alternating.

Samples

Sample Input 1

3
2
10
4
0110
8
11101000

Sample Output 1

0
1
2

Note

In the first test case, string 10 is already alternating.

In the second test case, we can, for example, reverse the last two elements of ss and get: 0110 \rightarrow 0101.

In the third test case, we can, for example, make the following two operations:

  1. 11101000 \rightarrow 10101100;
  2. 10101100 \rightarrow 10101010.