L,K=map(int,input().split()) S=input() T=input() o=(K+1)*L*(2*(L+1)) u1=(2*(L+1))*L dp=[0]*o dp[L]=1 mod=998244353 A=list(map(int,input().split())) z=sum(A) z=pow(z,-1,mod) p=z*11 p%=mod e=2*(L+1) def f(p,q): ans=p*q ans%=mod return ans for i in range(K): for j in range(L): for k in range(-L,L+1): if dp[i*u1+j*e+(k+L)]==0: continue if k==-L or k==L: dp[(i+1)*u1+j*e+k+L]+=dp[i*u1+j*e+k+L] dp[(i+1)*u1+j*e+k+L]%=mod else: a,b=S[j],T[(j-k)%L] x1=ord(a)-ord('a') x2=ord(b)-ord('a') p1,p2=A[x1]*z,A[x2]*z p1%=mod p2%=mod if a==b: w=i*u1+j*e+k+L w1=(i+1)*u1+((j+1)%L)*e+k+L w2=(i+1)*u1+j*e+k+L dp[w1]+=dp[w]*p1 dp[w2]+=dp[w]*(1-p1) dp[w1]%=mod dp[w2]%=mod else: w=i*u1+j*e+k+L w1=(i+1)*u1+((j+1)%L)*e+k+1+L w2=(i+1)*u1+j*e+k-1+L w3=(i+1)*u1+j*e+k+L dp[w1]+=dp[w]*p1 dp[w2]+=dp[w]*p2 dp[w3]+=dp[w]*(1-p1-p2) dp[w1]%=mod dp[w2]%=mod dp[w3]%=mod ans1=0 ans2=0 l=0 for j in range(L): ans1+=dp[K*u1+j*e+L+L] ans2+=dp[K*u1+j*e+L-L] ans1%=mod ans2%=mod print(ans1,ans2)