import sequtils,strutils,algorithm,math,sugar,macros,strformat template times*(n:int32,body) = (for _ in 0.." .} proc scan(): int32 = var minus = false while true: var k = getchar_unlocked() if k == '-' : minus = true elif k < '0' or k > '9': break else: result = 10 * result + k.ord.int32 - '0'.ord.int32 if minus: result *= -1 let n = scan() let m = scan() let S = stdin.readLine() var DC = newSeq[(int32,int32)]() var CA = newSeq[int32]() var ans = newSeq[int32](n) m.times: var u = scan() - 1 var v = scan() - 1 if S[u] < S[v]: (u,v) = (v,u) if S[u] == 'P' and S[v] == 'D' : ans[v] += 1 elif S[u] == 'D' and S[v] == 'C' : DC &= (u,v) elif S[u] == 'C' and S[v] == 'A' : CA &= u for dc in DC: ans[dc[1]] += ans[dc[0]] echo CA.mapIt(ans[it]).sum() mod 1000000007