L,K=map(int,input().split()) S=input() T=input() dp=[[[0]*(2*(L+1)) for i in range(L)] for j in range(K+1)] mod=998244353 A=list(map(int,input().split())) z=sum(A) z=pow(z,-1,mod) p=z*11 p%=mod dp[0][0][0]=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][j][k]==0: continue if k==-L or k==L: dp[i+1][j][k]+=dp[i][j][k] dp[i+1][j][k]%=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: dp[i+1][(j+1)%L][k]+=dp[i][j][k]*p1 dp[i+1][j][k]+=dp[i][j][k]*(1-p1) dp[i+1][(j+1)%L][k]%=mod dp[i+1][j][k]%=mod else: dp[i+1][(j+1)%L][k+1]+=dp[i][j][k]*p1 dp[i+1][j][k-1]+=dp[i][j][k]*p2 dp[i+1][j][k]+=dp[i][j][k]*(1-p1-p2) dp[i+1][(j+1)%L][k+1]%=mod dp[i+1][j][k-1]%=mod dp[i+1][j][k]%mod ans1=0 ans2=0 l=0 for j in range(L): ans1+=dp[K][j][L] ans2+=dp[K][j][-L] ans1%=mod ans2%=mod print(ans1,ans2)