Mr. X found a string of length , 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 from the string and toggle all the characters from to (toggle means 0 to 1, and 1 to 0). He will do this operation times.
But he has a lot of works to do and doesn't have enough time to perform this operations. So he is interested to know the expected value of the string, after performing operations. Assume that probability of each segment being selected is same.
First contains an integer (), 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 and ().
Second line of each test case contains a binary string of length.
For each test case, print the expected value of the string after performing operation in a single line.
If the answer is
then print it as
Input | Output |
---|---|
1 2 1 00 | 333333337 |