#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; constexpr ll MOD = 1000000000 + 7; int N, M; std::string S; std::vector

G; int cntP[100100], cntA[100100]; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N >> M; std::cin >> S; for(int i=0;i> u >> v; --u; --v; if(S[u] > S[v]){ std::swap(u, v); } G.emplace_back(u, v); if(S[u] == 'A'){ cntA[v] += 1; } if(S[v] == 'P'){ cntP[u] += 1; } } ll res = 0; for(auto &p : G){ int u, v; std::tie(u, v) = p; if(S[u] == 'C' && S[v] == 'D'){ res = (res + 1ll * cntP[v] * cntA[u] % MOD) % MOD; } } std::cout << res << std::endl; }