This page is still under construction.

Parts of this page are still being built. What you see may change.

String Game

Time limit2sMemory limit256 MB

Summary
Count the distinct binary strings of length k reachable from a given string by deleting 000 or 11 or swapping adjacent unequal characters.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics, String, Math
Solved
No attempts yet

Problem

Grisha and Dima are playing a game again. This time they have a string of zeros and ones. The following operations can be performed on the string:

  • delete three consecutive ones;
  • delete two consecutive zeros;
  • replace the substring "01" with the substring "10";
  • replace the substring "10" with the substring "01".

For example, in one operation the string "00111" can become the strings "00", "111", and "01011".

Now the boys are interested in the following question: how many distinct strings of length kk can be obtained from the given string using the described operations. Grisha and Dima are busy with their exams, so they ask you to help them.

Given a string and a number kk, determine how many distinct strings of length kk can be obtained from the given string using the described operations.

Input

The first line contains a positive integer tt (1≤t≤10001 \le t \le 1000), the number of test cases in the input. The descriptions of the test cases follow.

Each test case is described by two lines. The first line contains two positive integers nn and kk (1≤k≤n≤1001 \le k \le n \le 100), the length of the original string and the length of the string to be obtained. The second line contains a string of length nn consisting of zeros and ones.

Output

Output tt lines. For each test case, output the number of strings of length kk that can be obtained from the given string using the described operations. Since the answer can be quite large, output it modulo 109+710^9 + 7.

Examples1

  1. Example 1

    Input
    4
    2 2
    10
    4 2
    0000
    5 2
    01010
    5 2
    10101
    
    Expected output
    2
    1
    0
    1