Sherlock and Probability
Difficulty: Hard

Watson gave a string $S$ to Sherlock. It is $N$ characters long and consists of only `1`s and `0`s. Now he asks:  	Given an integer $K$, I'll pick two indices $i$ and $j$ at random between $1$ and $N$, both inclusive. What's the probability that both $S[i]$ and $S[j]$ are `1` and $|i - j| \le K$?

**Input Format**   
First line contains $T$, the number of testcases. Each testcase consists of $N$(the length of $S$) and $K$ in one line and string in second line.     

**Output Format**  
Print the required probability as an irreducible fraction. If required answer is `0`, output `0/1`.   

**Constraints**   
$1 \le T \le 10^5$  
$1 \le N \le 10^5$  
$1 \le K \le N$   
$1 \le \text{Sum of N over all testcases in one file} \le 10^5$    

**Sample input**   

    2
    4 3
    1011
    4 1
    1011
    
**Sample output**   

	9/16
    5/16
    
**Explanation**    
test1: Out of 16 choices, 9 pairs of $(i,j)$ satisfy our condition.  

    (1,1), (1,3), (1,4), (3,1), (3,3), (3,4), (4,1), (4,3), (4,4)      

test2: Out of 16 choices, 5 pairs of $(i,j)$ satisfy our condition.   

    (1,1), (3,3), (4,4), (4,3), (3,4)  

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:
#
# Complete the 'solve' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
#  1. INTEGER n
#  2. INTEGER k
#  3. STRING s
#

def solve(n, k, s):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) for(i=0;i<b;i++)
#define rep1(i,b) for(i=1;i<=b;i++)
#define pdn(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define pn printf("\n")
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define MOD 1000000007
LL mpow(LL a, LL n) 
{LL ret=1;LL b=a;while(n) {if(n&1) 
ret=(ret*b)%MOD;b=(b*b)%MOD;n>>=1;}
return (LL)ret;}
LL gcd(LL a, LL b)
{
    if(b==0)return a;return gcd(b,a%b);
}
LL pre[100005]={};
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        string s;
        LL n,k,i,j,ans=0;
        cin >> n >> k;
        cin >> s;
        for(i=0; i<=n; i++)pre[i]=0;
        for(i=1; i<=n; i++)
        {
                pre[i]=pre[i-1];
                if(s[i-1]=='1')pre[i]++;
        }
        for(i=1; i<=n; i++)
        {
                if(s[i-1]=='0')continue;
                ans += pre[min(n,i+k)]-pre[max(0ll,i-k-1)];
        }
        LL gc=gcd(ans,n*n);
        cout << ans/gc << "/" << (n*n)/gc << endl;
    }
    return 0;
}
```