You are given string $s$ of length $n$ consisting of 0-s and 1-s. You build an infinite string $t$ as a concatenation of an infinite number of strings $s$, or $t = ssss \dots$ For example, if $s =$ 10010, then $t =$ 100101001010010...

Calculate the number of prefixes of $t$ with balance equal to $x$. The balance of some string $q$ is equal to $cnt_{0, q} - cnt_{1, q}$, where $cnt_{0, q}$ is the number of occurrences of 0 in $q$, and $cnt_{1, q}$ is the number of occurrences of 1 in $q$. The number of such prefixes can be infinite; if it is so, you must say that.

A prefix is a string consisting of several first letters of a given string, without any reorders. An empty prefix is also a valid prefix. For example, the string "abcd" has 5 prefixes: empty string, "a", "ab", "abc" and "abcd".


-----Input-----

The first line contains the single integer $T$ ($1 \le T \le 100$) — the number of test cases.

Next $2T$ lines contain descriptions of test cases — two lines per test case. The first line contains two integers $n$ and $x$ ($1 \le n \le 10^5$, $-10^9 \le x \le 10^9$) — the length of string $s$ and the desired balance, respectively.

The second line contains the binary string $s$ ($|s| = n$, $s_i \in \{\text{0}, \text{1}\}$).

It's guaranteed that the total sum of $n$ doesn't exceed $10^5$.


-----Output-----

Print $T$ integers — one per test case. For each test case print the number of prefixes or $-1$ if there is an infinite number of such prefixes.


-----Example-----
Input
4
6 10
010010
5 3
10101
1 0
0
2 0
01

Output
3
0
1
-1



-----Note-----

In the first test case, there are 3 good prefixes of $t$: with length $28$, $30$ and $32$.

Difficulty: interview

Starter code:

Solutions:
t=int(input())
for i in ' '*t:
    n,x=map(int,input().split())
    s=input()
    L=[0]
    for i in s:
        if i=='0':L.append(L[-1]+1)
        else:L.append(L[-1]-1)
    L.pop(0)
    k=L[-1]
    c=0
    if x==0:c+=1
    if k>0:
        for i in L:
            if i%k==x%k and i<=x:c+=1
        print(c)
    elif k<0:
        for i in L:
            if i%k==x%k and i>=x:c+=1
        print(c)
    else:
        for i in L:
            if i==x:c=-1
        print(c)

import sys
input=sys.stdin.readline
t=int(input())
for _ in range(t):
    n,x=list(map(int,input().split()))
    s=input()
    pre=[1]
    if s[0]=="1":
        pre[0]=-1
    for i in range(1,2*n):
        pre.append(pre[i-1]+1)
        if i>=n:
            i-=n
        if s[i]=="1":
            pre[-1]-=2
    if pre[:n]==pre[n:]:
        if x in pre:
            print(-1)
        else:
            print(0)
    else:
        tot=0
        if x==0:
            tot+=1
        for i in range(n):
            if (x-pre[i])%(pre[i+n]-pre[i])==0:
                if(pre[i]<pre[i+n] and x<pre[i]):
                    continue
                if(pre[i]>pre[i+n] and x>pre[i]):
                    continue
                tot+=1
        print(tot)   

    


from collections import Counter

for _ in range(int(input())):
    n, x = list(map(int, input().split()))
    cnt = Counter()
    bal = 0
    for c in input():
        cnt[bal] += 1
        bal += (c == '0') - (c == '1')
    if bal == 0:
        if cnt[x]:
            print(-1)
        else:
            print(0)
    else:
        ans = 0
        for k in list(cnt.keys()):
            xmk = x - k
            if not xmk % bal and xmk * bal >= 0:
                ans += cnt[k]
        print(ans)


for _ in range(int(input())):
	n, x = map(int, input().split())

	s = input()

	pref = [0]

	for i in range(n):
		pref.append(pref[-1] + 2 * (s[i] == '0') - 1)

	jump = pref.pop()

#	print(pref, jump)

	if jump == 0:
		print(-1 * (min(pref) <= x <= max(pref)))
	else:

		tot = 0

		for delta in pref:
			if (x - delta) % jump == 0 and (x - delta) // jump >= 0:
				tot += 1

		print(tot)

sd = []
for _ in range(int(input())):
    n, x = map(int, input().split())
    s = input()
    bal = []
    b = 0
    for c in s:
        if c == '0':
            b += 1
        else:
            b -= 1
        bal.append(b)
    ans = 0
    for d in bal:
        if x == d and b == 0:
            ans = -1
            break
        elif b != 0:
            if (x - d) % b == 0 and ((x - d) // b) >= 0:
                ans += 1
    if x == 0 and ans != -1:
        ans += 1
    sd.append(str(ans))
print('\n'.join(sd))

t = int(input())
for i in ' ' * t:
    n, x = map(int, input().split())
    s = input()
    L = [0]
    for i in s:
        if i == '0':
            L.append(L[-1] + 1)
        else:
            L.append(L[-1] - 1)
    k = L.pop()
    c = 0
    if k > 0:
        for i in L:
            if i % k == x % k and i <= x: c += 1
        print(c)
    elif k < 0:
        for i in L:
            if i % k == x % k and i >= x: c += 1
        print(c)
    else:
        for i in L:
            if i == x: c = -1
        print(c)

for _ in range(int(input())):
    n,x=map(int,input().split())
    s=input()
    y=s.count('0')-s.count('1')
    z=0
    inf=False
    ans=0
    if x==0: ans=1
    for i in s:
        z+=(i=='0')-(i=='1')
        if y==0 and z==x:
            inf=True
            print(-1)
            break
        if x-z==0 or ((x-z)*y>0 and (x-z)%y==0):ans+=1
    if not inf:
        print(ans)

t = int(input())

while t:
    t -= 1
    n, x = map(int, input().split())
    a = list((-1 if int(i) else 1) for i in input())
    s = [0] * n
    s[0] = a[0]
    for i in range(1, n):
        s[i] = s[i - 1] + a[i]
    
    
    if s[-1] == 0:
        if x in s:
            print(-1)
        else:
            print(0)
    else:
        res = 1 if (x == 0) else 0
        for i in range(n):
            gap = x - s[i]
            if gap % s[-1] == 0 and gap // s[-1] >= 0:
                res += 1
        print(res)        

T = int(input())
for _ in range(T):
    n, x = map(int, input().split())
    S = input()
    A = [0] * n
    for i, s in enumerate(S):
        A[i] = A[i-1] + (1 if s == "0" else -1)
    t = A[-1]
    A[-1] = 0
    if t > 0:
        print(len([a for a in A if (x-a) % t == 0 and a <= x]))
    elif t < 0:
        print(len([a for a in A if (x-a) % (-t) == 0 and a >= x]))
    else:
        print(-1 if A.count(x) else 0)

import sys
t = int(input())
for e in range(t):
	
	n, x = list(map(int, input().split()))
	dp = [0 for i in range(n + 1)]
	s = input()
	cur = 0
	for i in range(n):
		if(s[i] == '0'):
			cur += 1	
		else:
			cur -= 1
		dp[i + 1] = cur
	# print(dp)

	if(dp[-1] == 0):
		if(min(dp) <= x <= max(dp)):
			print(-1)
		else:
			print(0)
		continue
	cnt = 0
	for i in range(n):
		diff = x-dp[i]
		# print(i, diff)
		if((diff)*dp[-1] >= 0 and diff%dp[-1] == 0):
			cnt += 1
	print(cnt)



import sys
input=sys.stdin.readline
t=int(input())
for _ in range(t):
    n,x=list(map(int,input().split()))
    s=input()
    pre=[1]
    if s[0]=="1":
        pre[0]=-1
    for i in range(1,2*n):
        pre.append(pre[i-1]+1)
        if i>=n:
            i-=n
        if s[i]=="1":
            pre[-1]-=2
    if pre[0]==pre[n]:
        if x in pre:
            print(-1)
        else:
            print(0)
    else:
        tot=0
        if x==0:
            tot+=1
        for i in range(n):
            
            if (x-pre[i])%(pre[i+n]-pre[i])==0:
                y=(x-pre[i])//(pre[i+n]-pre[i])
                if y<0:
                    continue
                tot+=1
        print(tot)   

    


for _ in range(int(input())):
    n,x=map(int,input().split())
    s=input()
    y=s.count('0')-s.count('1')
    z=0
    inf=False
    ans=0
    if x==0: ans=1
    for i in s:
        z+=(i=='0')-(i=='1')
        if y==0 and z==x:
            inf=True
            print(-1)
            break
        if x-z==0 or ((x-z)*y>0 and abs((x-z))%abs(y)==0):ans+=1
    if not inf:
        print(ans)