#include using namespace std; #define int long long const int MOD = 1e9+7; signed main(){ cin.tie(0); ios::sync_with_stdio(false); int n,m; cin >> n >> m; string s; cin >> s; vector G[n]; for(int i = 0; i < m; i++){ int u,v; cin >> u >> v; u--,v--; G[u].push_back(v); G[v].push_back(u); } vector dp(n,0); string PDCA = "PDCA"; for(int i = 0; i < n; i++){ if(s[i] == 'P') dp[i]++; } for(int j = 0; j < 3; j++){ for(int i = 0; i < n; i++){ for(int v : G[i]){ if(s[i] == PDCA[j] && s[v] == PDCA[j+1]){ dp[v] += dp[i]; dp[v] %= MOD; } } } } int ans = 0; for(int i = 0; i < n; i++){ if(s[i] == 'A'){ ans += dp[i]; ans %= MOD; } } cout << ans << endl; return 0; }