human
Bertown is a city with n buildings in a straight line.

The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the building number i and "0" otherwise.

Bertown's best sapper knows how to activate mines so that the buildings above them are not damaged. When a mine under the building numbered x is activated, it explodes and activates two adjacent mines under the buildings numbered x-1 and x+1 (if there were no mines under the building, then nothing happens). Thus, it is enough to activate any one mine on a continuous segment of mines to activate all the mines of this segment. For manual activation of one mine, the sapper takes a coins. He can repeat this operation as many times as you want.

Also, a sapper can place a mine under a building if it wasn't there. For such an operation, he takes b coins. He can also repeat this operation as many times as you want.

The sapper can carry out operations in any order.

You want to blow up all the mines in the city to make it safe. Find the minimum number of coins that the sapper will have to pay so that after his actions there are no mines left in the city.

Input

The first line contains one positive integer t (1 ≤ t ≤ 10^5) — the number of test cases. Then t test cases follow.

Each test case begins with a line containing two integers a and b (1 ≤ a, b ≤ 1000) — the cost of activating and placing one mine, respectively.

The next line contains a map of mines in the city — a string consisting of zeros and ones.

The sum of the string lengths for all test cases does not exceed 10^5.

Output

For each test case, output one integer — the minimum number of coins that the sapper will have to pay.

Example

Input

2
1 1
01000010
5 1
01101110

Output

2
6

Note

In the second test case, if we place a mine under the fourth building and then activate it, then all mines on the field are activated. The cost of such operations is six, b=1 coin for placing...
The above is tricky. Write me a correct solution in PYTHON3.
 Can you provide a Python code to find the minimum number of coins that the sapper will have to pay so that after his actions there are no mines left in the city?
assistant
#Here is Python code to find the minimum number of coins that the sapper will have to pay so that after his actions there are no mines left in the city.

#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
 
from itertools import groupby
def main():
    for _ in range(int(input())):
        ca,cp=map(int,input().split(" "))
        s=input()
        a=[[x,len(list(y))] for x,y in groupby(s)]
        n=len(a)
        if n==1 and a[0][0]=='0':
            print(0)
        else:
            if a[n-1][0]=='0':
                a.pop(n-1)
            if a[0][0]=='0':
                a.pop(0)
            ans=ca
            n=len(a)
            x=0
            while x<n:
                if a[x][0]=='0':
                    if a[x][1]*cp<=ca:
                       ans+=a[x][1]*cp
                       x+=2
                    else:
                        ans+=ca
                        x+=1
                else:
                    x+=1
            print(ans)




       

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
  ...