#include using namespace std; const long long MOD = 1000000007; template struct binary_indexed_tree{ int N; vector BIT; binary_indexed_tree(int N): N(N), BIT(N + 1, 0){ } void add(int i, T x){ i++; while (i <= N){ BIT[i] += x; i += i & -i; } } T sum(int i){ T ans = 0; while (i > 0){ ans += BIT[i]; i -= i & -i; } return ans; } T sum(int L, int R){ return sum(R) - sum(L); } }; int main(){ int N, K; cin >> N >> K; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector s(K); for (int i = 0; i < K; i++){ cin >> s[i]; } vector B = A; sort(B.begin(), B.end()); B.erase(unique(B.begin(), B.end()), B.end()); for (int i = 0; i < N; i++){ A[i] = lower_bound(B.begin(), B.end(), A[i]) - B.begin(); } int cnt = B.size(); vector> dp(K + 1, vector(N, 0)); for (int i = 0; i < N; i++){ dp[0][i] = 1; } for (int i = 0; i < K; i++){ binary_indexed_tree BIT(cnt); for (int j = 0; j < N; j++){ if (s[i] == '<'){ dp[i + 1][j] = BIT.sum(0, A[j]) % MOD; } if (s[i] == '>'){ dp[i + 1][j] = BIT.sum(A[j] + 1, cnt) % MOD; } BIT.add(A[j], dp[i][j]); } } long long ans = 0; for (int i = 0; i < N; i++){ ans += dp[K][i]; } ans %= MOD; cout << ans << endl; }