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; bool hasMemo; long memo; 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 ans = 0; foreach(nd1; nodes){ if(nd1.value != 'P') continue; if(! nd1.hasMemo){ nd1.memo = 0; foreach(nd2; nd1.nodes){ if(nd2.value != 'D') continue; if(! nd2.hasMemo){ nd2.memo = 0; foreach(nd3; nd2.nodes){ if(nd3.value != 'C') continue; if(! nd3.hasMemo){ nd3.memo = 0; foreach(nd4; nd3.nodes){ if(nd4.value != 'A') continue; nd3.memo += 1; nd3.memo %= MOD; } nd3.hasMemo = 1; } nd2.memo += nd3.memo; nd2.memo %= MOD; } nd2.hasMemo = 1; } nd1.memo += nd2.memo; nd1.memo %= MOD; } nd1.hasMemo = 1; } ans += nd1.memo; ans %= MOD; } ans.writeln; }