import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int l = Integer.parseInt(sa[0]); int k = Integer.parseInt(sa[1]); char[] s = br.readLine().toCharArray(); char[] t = br.readLine().toCharArray(); sa = br.readLine().split(" "); int[] a = new int[26]; int sum = 0; for (int i = 0; i < 26; i++) { a[i] = Integer.parseInt(sa[i]); sum += a[i]; } br.close(); int mod = 998244353; long sm = modinv(sum, mod); long[] b = new long[26]; for (int i = 0; i < 26; i++) { b[i] = a[i] * sm % mod; } long[] b1 = new long[26]; for (int i = 0; i < 26; i++) { b1[i] = (sum - a[i]) * sm % mod; } long[][] b2 = new long[26][26]; for (int i = 0; i < 26; i++) { for (int j = 0; j < 26; j++) { b2[i][j] = (sum - a[i] - a[j]) * sm % mod; } } int[][] dp = new int[1][1]; dp[0][0] = 1; long x = 0; long y = 0; for (int z = 0; z < k; z++) { int[][] wk = new int[z + 2][z + 2]; for (int i = 0; i <= z; i++) { for (int j = 0; j <= z; j++) { if (dp[i][j] == 0) { continue; } int p1 = i % l; int p2 = j % l; if (s[p1] == t[p2]) { int c = s[p1] - 'a'; wk[i + 1][j + 1] += dp[i][j] * b[c] % mod; wk[i + 1][j + 1] %= mod; wk[i][j] += dp[i][j] * b1[c] % mod; wk[i][j] %= mod; } else { int c1 = s[p1] - 'a'; wk[i + 1][j] += dp[i][j] * b[c1] % mod; wk[i + 1][j] %= mod; int c2 = t[p2] - 'a'; wk[i][j + 1] += dp[i][j] * b[c2] % mod; wk[i][j + 1] %= mod; wk[i][j] += dp[i][j] * b2[c1][c2] % mod; wk[i][j] %= mod; } } } for (int i = 0; i + l <= z + 1; i++) { x += wk[i + l][i]; wk[i + l][i] = 0; y += wk[i][i + l]; wk[i][i + l] = 0; } x %= mod; y %= mod; dp = wk; } System.out.println(x + " " + y); } static long modinv(long a, int m) { long b = m; long u = 1; long v = 0; long tmp = 0; while (b > 0) { long t = a / b; a -= t * b; tmp = a; a = b; b = tmp; u -= t * v; tmp = u; u = v; v = tmp; } u %= m; if (u < 0) u += m; return u; } }