#include using namespace std; using ll = long long; const ll MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; string s; cin >> n >> m >> s; vector< vector > g(n); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } vector cntp(n, 0); for (int i = 0; i < n; i++) { if (s[i] != 'P') continue; for (int j : g[i]) { cntp[j] += (s[j] == 'D'); } } vector cnta(n, 0); for (int i = 0; i < n; i++) { if (s[i] != 'C') continue; for (int j : g[i]) { cnta[i] += (s[j] == 'A'); } } ll ans = 0; for (int i = 0; i < n; i++) { if (s[i] != 'D') continue; for (int j : g[i]) { if (s[j] != 'C') continue; (ans += cntp[i] * cnta[j] % MOD) %= MOD; } } cout << ans << endl; return 0; }