#include #include using namespace std; using namespace atcoder; using ll=int; using ld=long double; ld pie=3.141592653589793; ll inf=1444999994; ll mod=1000000007; int main(){ ll n,k; cin >> n >> k; vectora(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } string s; cin >> s; vector>dp(k+1,vector(n,0)); vector>dai(n),syo(n); for (ll i = 0; i < n; i++) { for (ll j = i+1; j < n; j++) { if (a[i]>a[j]) { syo[i].push_back(j); }else if (a[i]') { for (ll k = 0; k < syo[j].size(); k++) { dp[i+1][syo[j][k]]+=dp[i][j]; if (dp[i+1][syo[j][k]]>mod) { dp[i+1][syo[j][k]]-=mod; } } }else{ for (ll k = 0; k < dai[j].size(); k++) { dp[i+1][dai[j][k]]+=dp[i][j]; if (dp[i+1][dai[j][k]]>mod) { dp[i+1][dai[j][k]]-=mod; } } } } } ll ans=0; for (ll i = 0; i