#define _USE_MATH_DEFINES #include using namespace std; const int mod = 1e9 + 7; int n, m; string s, t = "PDCA"; vector g[100005]; int dfs(int cur, int depth) { if (s[cur] != t[depth]) return 0; else { if (depth == 3) return 1; int res = 0; for (int nbr : g[cur]) { res += dfs(nbr, depth + 1); res %= mod; } return res; } } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; cin >> s; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; x--; y--; g[x].push_back(y); g[y].push_back(x); } int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'P') ans = ans + dfs(i, 0) % mod; } cout << ans << endl; return 0; }