#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i #define VLL vector #define VVI vector> #define VVLL vector> #define VC vector #define VS vector #define VVC vector> #define fore(i,a) for(auto &i:a) typedef pair P; template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 2147483647; const ll INFL = 9223372036854775807; const ll mod = 1000000007; VI a[100005]; string s; int res[100005][3] = {}; int main() { int n, m; cin >> n >> m >> s; cout << 'a' << endl; REP(i, m) { int u, v; cin >> u >> v; u--, v--; a[u].push_back(v); a[v].push_back(u); } REP(i, n) { if (s[i] != 'P')continue; for (int j : a[i]) { if (s[j] == 'D')res[j][0]++; } } REP(i, n) { if (s[i] != 'D')continue; for (int j : a[i]) { if (s[j] == 'C')res[j][1] += res[i][0]; } } ll ans = 0; REP(i, n) { if (s[i] != 'C')continue; for (int j : a[i]) { if (s[j] == 'A') { ans += res[i][1]; ans %= mod; } } } cout << ans << endl; return 0; }