#include #include #include using namespace std; using namespace atcoder; using mint = modint1000000007; void compress(vector &a) { auto sorted{a}; sort(sorted.begin(), sorted.end()); sorted.erase(unique(sorted.begin(), sorted.end()), sorted.end()); for (auto &&x : a) { x = lower_bound(sorted.begin(), sorted.end(), x) - sorted.begin(); } } int main() { int n, k; cin >> n >> k; vector a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } compress(a); string s; cin >> s; vector dp(n + 1, vector(k + 1)); vector t(k + 1, fenwick_tree(n)); for (int i = 0; i < n; i++) { dp.at(i + 1).at(0) = 1; t.at(0).add(a.at(i), 1); for (int j = 0; j <= k; j++) { dp.at(i + 1).at(j) += dp.at(i).at(j); if (j == k) continue; mint d; if (s.at(j) == '<') { d = t.at(j).sum(0, a.at(i)); } else { d = t.at(j).sum(a.at(i) + 1, n); } dp.at(i + 1).at(j + 1) += d; t.at(j + 1).add(a.at(i), d); } } cout << dp.back().back().val() << endl; return 0; }