class Fenwick_Tree: def __init__(self, n, mod): self.n = n self.data = [0] * n self.mod = mod def add(self, p, x): p += 1 while p <= self.n: self.data[p - 1] += x self.data[p - 1] %= self.mod p += p & -p def sum(self, l, r): '''範囲[l, r)(lからr-1まで)の総和を求める''' return (self._sum(r) - self._sum(l)) % self.mod def _sum(self, r): '''範囲[0, r)(0からr-1まで)の総和を求める''' s = 0 while r > 0: s += self.data[r - 1] s %= self.mod r -= r & -r return s from bisect import bisect_left def compression(lst): sort_lst = sorted(set(lst)) compression_lst = [None for _ in range(len(lst))] ele2ind_dict = dict() for i, ele in enumerate(lst): compression_lst[i] = bisect_left(sort_lst, ele) ele2ind_dict[ele] = compression_lst[i] return sort_lst, compression_lst, ele2ind_dict n, k = map(int, input().split()) A = list(map(int, input().split())) S = list(input()) mod = 10**9 + 7 sortedsetA, compA, _ = compression(A) compB = [len(sortedsetA) - ai - 1 for ai in compA] DP = [[0 for _ in range(n)] for _ in range(k + 1)] for i in range(n): DP[0][i] = 1 for i in range(k): s = S[i] FT = Fenwick_Tree(n, mod) if s == '<': L = compA else: L = compB for j in range(n): ele = L[j] FT.add(ele, DP[i][j]) if ele > 0: DP[i + 1][j] = FT._sum(ele) ans = 0 for i in range(n): ans += DP[k][i] ans %= mod print(ans)