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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
char s[75];int n,K,ans,a[75],p[305],inv[305];
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
void Check(int num,int sum)
{
	int pos=num+1,res=p[num],rnum=0,leftr=0,nxt=0,left=0;
	for(int i=1;i<=K;++i)
		if(s[i]=='r') rnum<num?leftr+=(a[++rnum]>1):(left?--left:0);
		else leftr?(--leftr,left+=a[++nxt]-2):(left?--left:0);
	if(left||rnum<num||leftr) return;
	for(int i=1,j;i<=num;i=j+1)
	{
		for(j=i;j<num&&a[j+1]==a[i];++j);
		res=1LL*res*inv[j-i+1]%mod;
		pos+=(j-i+1)*(a[i]*2-1);
	}
	ans=(ans+1LL*res*C(n-sum+pos-1,pos-1))%mod;
}
void dfs(int x,int num,int sum)
{
	if(sum>n) return;Check(num,sum);
	for(int i=x;i;--i) a[num+1]=i,dfs(i,num+1,sum+(i>1?i*2-3:1)+(num>0));
}
int main()
{
	scanf("%d%d%s",&n,&K,s+1);
	p[0]=inv[0]=p[1]=inv[1]=1;
	for(int i=2;i<=300;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=300;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod; 
	dfs(n,0,0);cout<<ans;
	return 0;
}