mod = 10**9 + 7 n, m = map(int, input().split()) assert 2 <= n <= 10**5 assert 0 <= m <= 10**5 s = input() assert len(s) == n assert all(c in 'PCDA' for c in s) graph = [[] for i in range(n)] for _ in range(m): u, v = map(int, input().split()) assert 1 <= u < v <= n assert (v-1) not in graph[u-1] assert (u-1) not in graph[v-1] graph[u - 1].append(v - 1) graph[v - 1].append(u - 1) nodes = {c: [] for c in 'PDCA'} pre = { 'D': 'P', 'C': 'D', 'A': 'C', } for i in range(n): nodes[s[i]].append(i) cnt = [1 if s[i] == 'P' else 0 for i in range(n)] for c in 'DCA': for v in nodes[c]: for u in graph[v]: if s[u] == pre[c]: cnt[v] += cnt[u] cnt[v] %= mod print(sum([cnt[v] for v in nodes['A']]) % mod)