Limits 3s, 512 MB

Mr. X found a string of length NN, which contains only 0 and 1. He calculates the value of a string by counting the number of 1 in it.

He decided to play with this string. He will randomly pick a segment (l,r)(l, r) from the string and toggle all the characters from ll to rr (toggle means 0 to 1, and 1 to 0). He will do this operation MM times.

But he has a lot of works to do and doesn't have enough time to perform this MM operations. So he is interested to know the expected value of the string, after performing MM operations. Assume that probability of each segment being selected is same.

Input

First contains an integer tt (1t1001 \le t \le 100), denotes the number of test cases.

Each of the next two lines describe a test case.

First line of each test case contains two integer NN and MM (1N,M10001 \le N, M \le 1000).

Second line of each test case contains a binary string of NN length.

Output

For each test case, print the expected value of the string after performing MM operation in a single line.

If the answer is

PQ\frac{P}{Q}

then print it as

(P×Q1)mod1000000007(P \times Q^{-1}) \mod 1000000007

Sample

InputOutput
1
2 1
00
333333337

Submit

Login to submit.

Statistics

73% Solution Ratio
IOI_StfuFfsEarliest, Mar '18
Kuddus.6068Fastest, 0.3s
IOI_StfuFfsLightest, 131 kB
IOI_StfuFfsShortest, 1626B
Toph uses cookies. By continuing you agree to our Cookie Policy.