#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; using ld=long double; using P=pair; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<> n >> m; string s; cin >> s; vector

edge(m); vector cntp(n, 0); vector cnta(n, 0); REP(i, m) { ll u, v; cin >> u >> v; u--; v--; edge[i] = P(u, v); if(s[u] == 'P') cntp[v]++; if(s[u] == 'A') cnta[v]++; if(s[v] == 'P') cntp[u]++; if(s[v] == 'A') cnta[u]++; } ll ans = 0; REP(i, m) { if(s[edge[i].first] == 'D' && s[edge[i].second] == 'C') { ans += cntp[edge[i].first] * cnta[edge[i].second]; ans %= MOD; } if(s[edge[i].first] == 'C' && s[edge[i].second] == 'D') { ans += cnta[edge[i].first] * cntp[edge[i].second]; ans %= MOD; } } cout << ans << endl; return 0; } /* --------------------------------------- */