AtCoder Regular Contest 089
F
ColoringBalls
AtCoder
⌀ 3782
原题
← E→
翻译中…

Problem Statement

翻译中…

There are $N$ white balls arranged in a row, numbered $1,2,..,N$ from left to right. AtCoDeer the deer is thinking of painting some of these balls red and blue, while leaving some of them white.

翻译中…

You are given a string $s$ of length $K$. AtCoDeer performs the following operation for each $i$ from $1$ through $K$ in order:

翻译中…
  • The $i$-th operation: Choose a contiguous segment of balls (possibly empty), and paint these balls red if the $i$-th character in $s$ is r; paint them blue if the character is b.
翻译中…

Here, if a ball which is already painted is again painted, the color of the ball will be overwritten. However, due to the properties of dyes, it is not possible to paint a white, unpainted ball directly in blue. That is, when the $i$-th character in $s$ is b, the chosen segment must not contain a white ball.

翻译中…

After all the operations, how many different sequences of colors of the balls are possible? Since the count can be large, find it modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $1$ $≤$ $N$ $≤$ $70$
  • $1$ $≤$ $K$ $≤$ $70$
  • $|s|$ $=$ $K$
  • $s$ consists of r and b.
  • $N$ and $K$ are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
s

翻译中…

Output

翻译中…

Print the number of the different possible sequences of colors of the balls after all the operations, modulo $10^9+7$.

翻译中…

样例

Input #1
2 2
rb
Output #1
9
There are nine possible sequences of colors of the balls, as follows: `ww`, `wr`, `rw`, `rr`, `wb`, `bw`, `bb`, `rb`, `br`. Here, `r` represents red, `b` represents blue and `w`represents white.
Input #2
5 2
br
Output #2
16
Since we cannot directly paint white balls in blue, we can only choose an empty segment in the first operation.
Input #3
7 4
rbrb
Output #3
1569
Input #4
70 70
bbrbrrbbrrbbbbrbbrbrrbbrrbbrbrrbrbrbbbbrbbrbrrbbrrbbbbrbbrbrrbbrrbbbbr
Output #4
841634130
题目信息
题号
arc089_d
时间限制
4 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。