#pragma GCC optimize ("-O3","unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<P; const int MAX = 200020; vectorG[100010]; int PDCA[100010], DCA[100010], CA[100010]; int N, M; string S; int ca(int n) { if (CA[n] != -1)return CA[n]; int ret = 0; for (auto x : G[n]) { if (S[x] == 'A') { ret++; ret %= MOD; } } CA[n] = ret; return ret; } int dca(int n) { if (DCA[n] != -1)return DCA[n]; int ret = 0; for (auto x : G[n]) { if (S[x] == 'C') { ret += ca(x); ret %= MOD; } } DCA[n] = ret; return ret; } int pdca(int n) { if (PDCA[n] != -1)return PDCA[n]; int ret = 0; for (auto x : G[n]) { if (S[x] == 'D') { ret += dca(x); ret %= MOD; } } PDCA[n] = ret; return ret; } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M >> S; REP(i, M) { int u, v; cin >> u >> v; u--, v--; G[u].pb(v); G[v].pb(u); } int ans = 0; REP(i, 100010) { PDCA[i] = -1; DCA[i] = -1; CA[i] = -1; } REP(i, N) { if (S[i] == 'P') { ans += pdca(i); ans %= MOD; } } print(ans); }