#include #include #define M 1000000007 using namespace std; int main(int argc, char** argv) { int n, m; string s; cin >> n >> m >> s; vector adj[100100]; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; adj[x].push_back(y); adj[y].push_back(x); } long long dp[4][100100] = {}; const string target = "ACDP"; for (int j = 1; j <= n; j++) if (s[j-1] == 'A') dp[0][j] = 1; for (int i = 1; i < 4; i++) for (int j = 1; j <= n; j++) { if (s[j-1] == target[i]) for (int k : adj[j]) dp[i][j] += dp[i-1][k]; dp[i][j] %= M; } long long ans = 0; for (int j = 1; j <= n; j++) ans += dp[3][j]; cout << ans % M << endl; }