Problem: You are given a set , which contains the first positive integers: .
You can perform the following operation on any number of times (possibly zero):
- Choose a positive integer where , such that there exists a multiple of in . Then, delete the smallest multiple of from . This operation requires a cost of .
You are given a set , which is a subset of . Find the minimum possible total cost of operations such that would be transformed into . We can show that such a transformation is always possible.
Input Format: The first line of the input contains a single integer () — the number of test cases. The description of the test cases follows.
The first line contains a single positive integer ().
The second line of each test case contains a binary string of length , describing the set . The -th character of the string is '1' if and only if is an element of , and '0' otherwise.
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, output one non-negative integer — the minimum possible total cost of operations such that would be transformed into .
Note: In the first test case, we shall not perform any operations as is already equal to , which is the set .
In the second test case, initially, , and . We shall perform the following operations:
- Choose , then delete from .
- Choose , then delete from .
- Choose , then delete from .
The total cost is . It can be shown that this is the smallest cost possible.
In the third test case, initially, and (empty set). We shall perform operations of to delete , , , and .
In the fourth test case, initially, and . We shall perform two operations with to delete and , then perform one operation with to delete .