Problem:
Score : 1100 points

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.

Sample Input 1

2 2
rb

Sample 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 wrepresents white.

Sample Input 2

5 2
br

Sample Output 2

16

Since we cannot directly paint white balls in blue, we can only choose an empty segment in the first operation.

Sample Input 3

7 4
rbrb

Sample Output 3

1569

Sample Input 4

70 70
bbrbrrbbrrbbbbrbbrbrrbbrrbbrbrrbrbrbbbbrbbrbrrbbrrbbbbrbbrbrrbbrrbbbbr

Sample Output 4

841634130

Solution in C (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <stdio.h>

#define N	70
#define K	70
#define MD	1000000007

int min(int a, int b) { return a < b ? a : b; }

int ch[N + 1][N + 1], cnt[N + 1][N + 1];

void init() {
	int n, b, k, l;

	ch[0][0] = 1;
	for (n = 1; n <= N; n++) {
		ch[n][0] = 1;
		for (k = 1; k <= n; k++)
			ch[n][k] = (ch[n - 1][k] + ch[n - 1][k - 1]) % MD;
	}
	for (n = 1; n <= N; n++) {
		cnt[n][0] = 1;
		for (b = 1; b <= (n + 1) / 2; b++)
			for (l = b; l <= n; l++)
				cnt[n][b] = (cnt[n][b] + (long long) ch[l - 1][b - 1] * ch[n - l + 1][b]) % MD;
	}
}

int main() {
	static char cc[N + 1];
	static int iir[N + 1], iib[N + 1], dp[N + 1][N + 1][N + 1];
	int n, m, mr, mb, c, h, i, j, k, i_, j_, k_, b, l, ans;

	init();
	scanf("%d%d%s", &n, &m, cc);
	mr = mb = 0;
	for (i = 0; i < m; i++)
		if (cc[i] == 'r')
			iir[mr++] = i;
		else
			iib[mb++] = i;
	ans = 1;
	for (c = 1; c <= (n + 1) / 2 && c <= mr; c++) {
		int n1 = n - c + 1, n2 = c, n3 = mb;

		for (i = 0; i <= n1; i++)
			for (j = 0; j <= n2; j++)
				for (k = 0; k <= n3; k++)
					dp[i][j][k] = 0;
		dp[0][0][0] = 1;
		for (b = 0; b <= mb; b++)
			for (l = b == 0 ? 1 : b * 2 - 1; l <= n1; l++) {
				int y = cnt[l][b];

				for (i = n1 - l; i >= 0; i--)
					for (j = n2 - 1; j >= 0; j--)
						for (k = n3 - b; k >= 0; k--) {
							int x = dp[i][j][k], p;

							if (x == 0)
								continue;
							p = 1;
							for (h = 1; (i_ = i + h * l) <= n1 && (j_ = j + h) <= n2 && (k_ = k + h * b) <= n3; h++) {
								if (b > 0 && iir[c - j_] > iib[mb - k_])
									break;
								p = (long long) p * y % MD;
								dp[i_][j_][k_] = (dp[i_][j_][k_] + (long long) x * p % MD * ch[j_][h]) % MD;
							}
						}
			}
		j = c;
		for (i = 0; i <= n1; i++)
			for (k = 0; k <= n3; k++)
				ans = (ans + (long long) dp[i][j][k] * ch[n - i + 1][j]) % MD;
	}
	printf("%d\n", ans);
	return 0;
}