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)] for rf2effe in range(k+2)] dp[0][0][0] = 1 ans = [0,0] for i in range(k+1): for j in range(k+1): for m in range(k+1): if abs(j-m) == l: if j > m: ans[0] += dp[i][j][m] ans[0] %= mod else: ans[1] += dp[i][j][m] ans[1] %= mod continue if abs(j-m) > l: continue if s[j%l] != t[m%l]: dp[i+1][j][m] += (dp[i][j][m] * (su - a[s[j%l]] - a[t[m%l]]) * inv) % mod dp[i+1][j+1][m] += (dp[i][j][m] * a[s[j%l]] * inv) % mod dp[i+1][j][m+1] += (dp[i][j][m] * a[t[m%l]] * inv) % mod else: dp[i+1][j][m] += (dp[i][j][m] * (su - a[s[j%l]]) * inv) % mod dp[i+1][j+1][m+1] += (dp[i][j][m] * a[s[j%l]] * inv) % mod print(*ans)