#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> N >> M; string s; cin >> s; vector U(M); vector V(M); FOR(i, 0, M){ ll u, v; cin >> u >> v; u--; v--; U[i] = u; V[i] = v; } // P->D FOR(i, 0, M){ ll u = U[i]; ll v = V[i]; if(s[u]=='P' && s[v]=='D'){ dp[v]++; } swap(u, v); if(s[u]=='P' && s[v]=='D'){ dp[v]++; } } // D->C FOR(i, 0, M){ ll u = U[i]; ll v = V[i]; if(s[u]=='D' && s[v]=='C'){ dp[v] += dp[u]; dp[v] %= mod; } swap(u, v); if(s[u]=='D' && s[v]=='C'){ dp[v] += dp[u]; dp[v] %= mod; } } // C->A FOR(i, 0, M){ ll u = U[i]; ll v = V[i]; if(s[u]=='C' && s[v]=='A'){ dp[v] += dp[u]; dp[v] %= mod; } swap(u, v); if(s[u]=='C' && s[v]=='A'){ dp[v] += dp[u]; dp[v] %= mod; } } ll sum = 0; FOR(i, 0, N){ if(s[i]=='A'){ sum += dp[i]; sum %= mod; } } p(sum); return 0; }