import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); char[] arr = sc.next().toCharArray(); ArrayList> graph = new ArrayList<>(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; graph.get(a).add(b); graph.get(b).add(a); } int[] pCounts = new int[n]; for (int i = 0; i < n; i++) { if (arr[i] == 'P') { pCounts[i]++; } } int[] dCounts = new int[n]; for (int i = 0; i < n; i++) { if (arr[i] != 'D') { continue; } for (int x : graph.get(i)) { dCounts[i] += pCounts[x]; dCounts[i] %= MOD; } } int[] cCounts = new int[n]; for (int i = 0; i < n; i++) { if (arr[i] != 'C') { continue; } for (int x : graph.get(i)) { cCounts[i] += dCounts[x]; cCounts[i] %= MOD; } } int total = 0; for (int i = 0; i < n; i++) { if (arr[i] != 'A') { continue; } for (int x : graph.get(i)) { total += cCounts[x]; total %= MOD; } } System.out.println(total); } }