import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container, std.format; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } const long MOD = 1000000007; class Node{ int id; char value; Node[] nodes; this(int id){ this.id = id; } override string toString(){ return this.id.to!string ~ " " ~ this.value; } } void main(){ int n = read.to!int; Node[] nodes; foreach(i; 0 .. n) nodes ~= new Node(i); int m = read.to!int; string s = readln.chomp; foreach(i, c; s) nodes[i].value = c; foreach(i; 0 .. m){ int u = read.to!int - 1, v = read.to!int - 1; nodes[u].nodes ~= nodes[v]; nodes[v].nodes ~= nodes[u]; } long temp1 = 0; foreach(nd1; nodes){ if(nd1.value != 'P') continue; long temp2 = 0; foreach(nd2; nd1.nodes){ if(nd2.value != 'D') continue; long temp3 = 0; foreach(nd3; nd2.nodes){ if(nd3.value != 'C') continue; long temp4 = 0; foreach(nd4; nd3.nodes){ if(nd4.value != 'A') continue; temp4 += 1; temp4 %= MOD; } temp3 += temp4; temp3 %= MOD; } temp2 += temp3; temp2 %= MOD; } temp1 += temp2; temp1 %= MOD; } auto ans = temp1; ans.writeln; }