QOJ.ac

QOJ

时间限制: 1 s 内存限制: 256 MB 总分: 100

#3680. Sequence Coloring

统计

Given a string $S$ of length $N$ consisting of the characters B, W, and X, you need to color each X as either B or W.

For a given $K$, find the number of ways to color the string such that there exist integers $a, b, c, d$ satisfying:

  • $1 \leq a \leq b < c \leq d \leq N$
  • $S_a, S_{a+1}, \dots, S_b$ are all B
  • $S_c, S_{c+1}, \dots, S_d$ are all W

where $b = a + K - 1$ and $d = c + K - 1$.

Since the number of ways can be large, output the result modulo $10^9 + 7$.

Input

The first line contains two positive integers $N$ and $K$.

The second line contains a string $S$ of length $N$.

Output

Output a single integer representing the answer modulo $10^9 + 7$.

Examples

Input 1

5 2
XXXXX

Output 1

4

Constraints

For $20\%$ of the data, $N \leq 20$.

For $50\%$ of the data, $N \leq 2\,000$.

For $100\%$ of the data, $1 \leq N \leq 10^6$, $1 \leq K \leq 10^6$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.