#arc119f. [arc119_f]AtCoder Express 3

[arc119_f]AtCoder Express 3

Problem Statement

There are N+1N+1 stations along the AtCoder Line, numbered 00 through NN. Formerly, it only had Local Trains, which run between Stations ii and i+1i + 1 in one minute in either direction for each ii (0leqileqN1)(0 \\leq i \\leq N-1).

One day, however, the railway company broke into two groups, called Ko-soku (light speed) and Jun-kyu (semi express). They decided that each station other than Stations 00 and NN should be administered by one of the groups. The group that administers Station jj (1leqjleqN1)(1 \\leq j \\leq N-1) is represented by a character cjc_j: A means that Ko-soku administers the station, B means Jun-kyu administers the station, and ? means it is undecided. Since Stations 00 and NN are so important, both groups will administer them.

Now, Ko-soku and Jun-kyu have decided to run two new types of trains, in addition to the local trains.

Ko-soku Trains: Let Stations a0,a1,dots,asa_0, a_1, \\dots, a_s be the stations administered by Ko-soku in ascending order. These trains run between Stations aka_k and ak+1a_{k+1} in one minute in either direction for each kk.

Jun-kyu Trains: Let Stations b0,b1,dots,btb_0, b_1, \\dots, b_t be the stations administered by Jun-kyu in ascending order. These trains run between Stations bkb_k and bk+1b_{k+1} in one minute in either direction for each kk.

There are 2q2^q ways in which these trains run, where qq is the number of ?s. Among them, how many enables us to go from Station 00 to Station NN in no more than KK minutes' ride? Find this count modulo (109+7)(10^9+7).

Constraints

  • 2leqNleq40002 \\leq N \\leq 4000
  • 1leqKleqfracN+121 \\leq K \\leq \\frac{N+1}{2}
  • NN and KK are integers.
  • Each of c1,c2,dots,cN1c_1, c_2, \\dots, c_{N-1} is A, B, or ?.

Input

Input is given from Standard Input in the following format:

NN KK c1c_1c2c_2cdots\\cdotscN1c_{N-1}

Output

Print the count modulo (109+7)(10^9+7).


Sample Input 1

8 3
A??AB?B

Sample Output 1

4

Here, there are 23=82^3 = 8 possible ways in which the trains run. Among them, the following four enable us to go from Station 00 to Station 88 in no more than 33 minutes' ride.

  • If Ko-soku administers Stations 2,3,62, 3, 6, we can go Station 0rightarrow5rightarrow7rightarrow80 \\rightarrow 5 \\rightarrow 7 \\rightarrow 8, as shown at #1 in the figure below.
  • If Ko-soku administers Stations 2,32, 3 and Jun-kyu administers Station 66, we can go Station 0rightarrow5rightarrow4rightarrow80 \\rightarrow 5 \\rightarrow 4 \\rightarrow 8, as shown at #2 in the figure below.
  • If Ko-soku administers Station 22 and Jun-kyu administers Stations 3,63, 6, we can go Station 0rightarrow3rightarrow4rightarrow80 \\rightarrow 3 \\rightarrow 4 \\rightarrow 8, as shown at #4 in the figure below.
  • If Jun-kyu administers Stations 2,3,62, 3, 6, we can go Station 0rightarrow1rightarrow4rightarrow80 \\rightarrow 1 \\rightarrow 4 \\rightarrow 8, as shown at #8 in the figure below.

Therefore, the answer is 44. The figure below shows all the possible ways, where red stations and railways are administered only by Ko-soku, and blue stations and railways are administered only by Jun-kyu.


Sample Input 2

11 6
???B??A???

Sample Output 2

256

Here, all of the 28=2562^8 = 256 ways enable us to go from Station 00 to Station 1111 in no more than 66 minutes' ride.


Sample Input 3

16 5
?A?B?A?B?A?B?A?

Sample Output 3

10

1010 ways shown in the figure below enable us to go from Station 00 to Station 1616 in no more than 55 minutes' ride.


Sample Input 4

119 15
????????A?????????????????????????BA????????????????????????AB???????A???????????B?????????????????????????????A??????

Sample Output 4

313346281

There are 16233103247094511623310324709451 desirable ways. Print this count modulo (109+7)(10^9 + 7), that is, 313346281313346281.