#P5772. [JSOI2016] 位运算

[JSOI2016] 位运算

Description

JYY has recently been studying bitwise operations. He found that the most interesting one is the xor operation. For the xor of two numbers, JYY discovered a fact: the xor of two numbers is 00 if and only if they are equal. Then JYY started thinking: what properties does the xor of NN numbers have?

JYY wants to know: within the range from 00 to R1R-1, choose NN distinct integers such that the xor of these NN integers is 00. How many different ways are there to choose them? (Different selection orders are not counted multiple times; see the sample.)

JYY is a computer scientist, so the RR in his mind is extremely large. To describe it conveniently, if we write RR as a binary string, then RR is obtained by repeating a shorter binary string SS for KK times. For example, if S=101S=101 and K=2K=2, then the binary representation of RR is 101101101101. Since the result can be very large, you only need to output the total number of ways modulo 109+710^9+7.

Input Format

The first line contains two positive integers NN and KK.

The next line contains a string SS consisting of characters 00 and 11.

It is guaranteed that the first character of SS is 11.

Output Format

Output one integer in one line, the number of valid selections modulo 109+710^9+7.

3 1
100
1

Hint

Sample Explanation

The only valid selection is {1,2,3}\{1,2,3\}.


Constraints

For 100%100\% of the testdata, 3N73 \le N \le 7, 1k1051 \le k \le 10^5, 1S501 \le |S| \le 50.

Translated by ChatGPT 5