#include using namespace std; const int MOD = int(1e9 + 7); signed main() { ios::sync_with_stdio(false); int N, M; cin >> N >> M; string S; cin >> S; vector> G(N); for (int i = 0; i < M; ++i) { int U, V; cin >> U >> V; G[U - 1].push_back(V - 1); G[V - 1].push_back(U - 1); } vector dp(N); for (int i = 0; i < N; ++i) dp[i] += S[i] == 'P'; for (int i = 0; i < N; ++i) if (S[i] == 'D') for (int j : G[i]) if (S[j] == 'P') (dp[i] += dp[j]) %= MOD; for (int i = 0; i < N; ++i) if (S[i] == 'C') for (int j : G[i]) if (S[j] == 'D') (dp[i] += dp[j]) %= MOD; int ans = 0; for (int i = 0; i < N; ++i) if (S[i] == 'A') for (int j : G[i]) if (S[j] == 'C') (ans += dp[j]) %= MOD; cout << ans << endl; return 0; }