# import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') N,M = map(int,input().split()) S = list(input()) mod = 998244353 import sys # sys.setrecursionlimit(10**6) d = {'P':0,'D':1,'C':2,'A':3} val = [0]*N S = [d[i] for i in S] e = [[] for _ in range(N)] for i in range(M): u,v = map(int,input().split()) u -= 1 v -= 1 if abs(S[u]-S[v])==1: if S[v]>S[u]: e[v].append(u) else: e[u].append(v) for i in range(N): if S[i]==3: val[i]=1 for i in range(3,0,-1): for j in range(N): if S[j]==i: for ix in e[j]: val[ix] = (val[ix]+val[j])%mod print(sum(val[i] for i in range(N) if S[i]==0)%mod) # print(val)