#include #include #include using namespace std; using namespace atcoder; using mint = modint1000000007; void compress_vec(vector& a){ vector b = a; sort(b.begin(), b.end()); b.erase(unique(b.begin(), b.end()), b.end()); unordered_map mp = {}; for(int i = 0; i < (int)b.size(); ++i){ mp[b[i]] = i; } for(int i = 0; i < (int)a.size(); ++i){ a[i] = mp[a[i]]; } } int main(){ int N, K; cin >> N >> K; vector a(N); for(auto& x : a){ cin >> x; } compress_vec(a); string s; cin >> s; vector > dp(K + 1, vector(N)); for(auto& x : dp[0]){ x = 1; } for(int i = 0; i < K; ++i){ fenwick_tree bt(N); for(int j = 0; j < N; ++j){ bt.add(a[j], dp[i][j]); if(s[i] == '<'){ dp[i + 1][j] = bt.sum(0, a[j]); } else{ dp[i + 1][j] = bt.sum(a[j] + 1, N); } } } mint ans = 0; for(auto& x : dp[K]){ ans += x; } cout << ans.val() << endl; return 0; }