import collections l,k = map(int,input().split()) s = list(input().rstrip()) t = list(input().rstrip()) for i in range(l): s[i] = ord(s[i]) - ord('a') t[i] = ord(t[i]) - ord('a') a = list(map(int,input().split())) mod = 998244353 inv = pow(sum(a),mod-2,mod) su = sum(a) dp = [[0 for i in range(k+2)] for j in range(k+2)] dp[0][0] = 1 ans = [0,0] for i in range(k+1): ndp = [[0 for wrfrf in range(k+2)] for fwfwf in range(k+2)] for j in range(k+1): for m in range(k+1): if abs(j-m) == l: if j > m: ans[0] += dp[j][m] ans[0] %= mod else: ans[1] += dp[j][m] ans[1] %= mod continue if abs(j-m) > l: continue if s[j%l] != t[m%l]: ndp[j][m] += (dp[j][m] * (su - a[s[j%l]] - a[t[m%l]]) * inv) % mod ndp[j+1][m] += (dp[j][m] * a[s[j%l]] * inv) % mod ndp[j][m+1] += (dp[j][m] * a[t[m%l]] * inv) % mod else: ndp[j][m] += (dp[j][m] * (su - a[s[j%l]]) * inv) % mod ndp[j+1][m+1] += (dp[j][m] * a[s[j%l]] * inv) % mod dp = ndp print(*ans)