Daily Disinfection

Time limit: 0.5s Memory limit: 256MB Input: Output:

We're gonna scour every vat, every keg, every cook surface. We've gotta clean up every possible source of contamination, and only then we cook. Comprende?

  • Jesse, Breaking Bad

To get 99.1%99.1\% pure product, everything in the lab has to be thoroughly cleaned daily.
Right now, Jesse is going to clean a shelf with books.

The shelf consists of nn places for books. There are some books placed on the shelf (possibly, none). If some place is empty, Jesse can clean it without any power consumption (he is really good at cleaning). He cannot clean any place with a book currently in it. If there is a book at some place, and the adjacent place is empty, Jesse can move the book to that adjacent place consuming 11 power.

Jesse is a very busy person, and he does not want to spend too much power. For each test case, tell the minimal amount of power Jesse has to spend.

Input data

The first line contains of the single integer tt (1t1051 \le t \le 10^5) - the number of the test cases.

The first line of each of the tt test cases contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5) - the number of the places on the shelf.

The second line contains a string ss of length nn, where si=0s_i = 0 if there is no book at ii-th place, and s1=1s_1 = 1 otherwise.

It is guaranteed that in all provided test cases it is possible to clean the shelf.

The sum of nn over all test cases will not be greater than 21052 \cdot 10^5.

Output data

Output tt lines, each line containing a single integer - the minimal amount of power Jesse has to spend.

Example

stdin

3
2
01
5
00110
9
101010101

stdout

1
2
6

Explanation

In the first test case, Jesse can clean the first place, then move the book from the second place to the first (consuming 11 power), and then clean the second place.

Log in or sign up to be able to send submissions!