CF2106A.Dr. TC

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

Dr. TC

In order to test his patients' intelligence, Dr. TC created the following test.

First, he creates a binary string^{\text{∗}} ss having nn characters. Then, he creates nn binary strings a1,a2,,ana_1, a_2, \ldots, a_n. It is known that aia_i is created by first copying ss, then flipping the ii'th character (1 becomes 0 and vice versa). After creating all nn strings, he arranges them into a grid where the ii'th row is aia_i.

For example,

  • If s=101s = \texttt{101}, a=[001,111,100]a = [\texttt{001}, \texttt{111}, \texttt{100}].
  • If s=0000s = \texttt{0000}, $a = [\texttt{1000}, \texttt{0100}, \texttt{0010}, \texttt{0001}]$.

The patient needs to count the number of 11s written on the board in less than a second. Can you pass the test?

^{\text{∗}}A binary string is a string that only consists of characters 1 and 0.

Input

The first line of the input consists of 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 (1n101 \le n \le 10) — the length of the binary string ss.

The second line of each test case contains a single binary string ss of size nn.

Output

For each test case, output a single integer, the number of 1s on the board.

Note

The first example is explained in the statement.

For the second example, the only string written on the board will be the string 0; therefore, the answer is 00.

In the third example, the following strings will be written on the board: $[\texttt{10000}, \texttt{01000}, \texttt{00100}, \texttt{00010}, \texttt{00001}]$; so there are five 1s written on the board.

Samples

5
3
101
1
1
5
00000
2
11
3
010
5
0
5
2
4

在线编程 IDE

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