Orig Description
Score : 1100 points
Problem StatementThere 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.
InputInput is given from Standard Input in the following format:
N K
s
OutputPrint the number of the different possible sequences of colors of the balls after all the operations, modulo 10^9+7.
Sample Input 12 2
rb
Sample Output 19
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 wrepresents white.
Sample Input 25 2
br
Sample Output 216
Since we cannot directly paint white balls in blue, we can only choose an empty segment in the first operation.
Sample Input 37 4
rbrb
Sample Output 31569
Sample Input 470 70
bbrbrrbbrrbbbbrbbrbrrbbrrbbrbrrbrbrbbbbrbbrbrrbbrrbbbbrbbrbrrbbrrbbbbr
Sample Output 4841634130
Extracted Specification
An integer N (1 ≤ N ≤ 70), representing some quantity or size.
An integer K (1 ≤ K ≤ 70), representing some quantity or size.
A string s of length K, consisting of characters 'r' and 'b'.
### Example Input:
```
12 2
rb
```
### Function Signature:
Write a function f(N, K, s) that takes in the input.
def f(N: int, K: int, s: str):
'''
N: an integer
K: an integer
s: a string
'''
Test Case Generator
Sure, here's a test case generator for the given problem statement:
### Test Case Generator for the Problem Statement
```python
import random
def tcgen():
N = random.randint(1, 70) # Generate a random N within the specified range
K = random.randint(1, 70) # Generate a random K within the specified range
s = ''.join(random.choice(['r', 'b']) for _ in range(K)) # Generate a random string of length K consisting of 'r' and 'b'
return N, K, s
# Example of generating a test case
def format_test_case(N, K, s):
return f"{N} {K}\n{s}"
# Generate a test case and print it
N, K, s = tcgen()
print(format_test_case(N, K, s))
```
### Explanation
1. **N**: Generates a random integer between 1 and 70, inclusive. This represents the number of balls.
2. **K**: Generates a random integer between 1 and 70, inclusive. This represents the length of the string `s`.
3. **s**: Creates a string of length `K` where each character is either 'r' or 'b', randomly chosen.
This ensures that the test cases generated respect the constraints given in the problem statement.
### Example Output
Below is an example of how a test case might look when generated:
```
56 45
rrbbrrbrbbrrrbbrbrbrrbbrrrbrbbrbrrbbbrrrbbrrbb
```
This output can be directly used as input for the problem's solution function.
Extract Arguments
def extract_arguments(fh):
N, K = map(int, fh.readline().strip().split())
s = fh.readline().strip()
return N, K, s
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# N, K, s = extract_arguments(fh)
# f(N, K, s)