#include #include #include #include using ll = long long; using P = std::pair; constexpr ll MOD = 1000000007; int main() { int N, M; std::cin >> N >> M; std::string S; std::cin >> S; std::vector

edge; std::vector from(N, 0), to(N, 0); for (int i = 0, u, v; i < M; i++) { std::cin >> u >> v, u--, v--; edge.push_back({ u,v }), edge.push_back({v,u}); if (S[u] == 'P' and S[v] == 'D') { from[v]++; } else if (S[u] == 'D' and S[v] == 'P') { from[u]++; } if (S[u] == 'C' and S[v] == 'A') { to[u]++; } else if (S[u] == 'A' and S[v] == 'C') { to[v]++; } } ll ans = 0; for (const auto& e : edge) { (ans += from[e.first] * to[e.second] % MOD) %= MOD; } std::cout << ans << std::endl; }