MOD = 10 ** 9 + 7 n, m = map(int, input().split()) S = input() edges = [[] for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 edges[u].append(v) edges[v].append(u) cnt = [0] * n for f, t in zip("PDC", "DCA"): for i, s in enumerate(S): if s == f: if f == "P": cnt[i] = 1 for j in edges[i]: if S[j] == t: cnt[j] += cnt[i] ans = 0 for i, s in enumerate(S): if s == "A": ans += cnt[i] print(ans % MOD)