//TLE(?) #include #include #define rep(i, l, n) for (int i = (l); i < (n); i++) using namespace std; using namespace atcoder; using ll = long long; template using V = vector; const ll mod = 1000000007; int main(void) { int N, K; cin >> N >> K; V a(N), b(N); rep(i, 0, N) { cin >> a[i]; } string s; cin >> s; V dp(N, 1); rep(i, 0, K) { V ndp(N); ll t = 1; if (s[i] == '>') { t = -1; } rep(j, 0, N) { rep(k, 0, j) { ndp[j] += ((a[k] - a[j]) * t < 0) * dp[k]; ndp[j] %= mod; } } rep(j, 0, N) { dp[j] = ndp[j]; } } ll ans = 0; for (ll t : dp) { ans += t; ans %= mod; } cout << ans << endl; return 0; }