import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int k = sc.nextInt(); char[] s = sc.next().toCharArray(); char[] t = sc.next().toCharArray(); int[] a = new int[26]; int sum = 0; for (int i = 0; i < 26; i++) { a[i] = sc.nextInt(); sum += a[i]; } sc.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; } } long[][] dp = new long[k + 1][k + 1]; dp[0][0] = 1; long x = 0; long y = 0; for (int z = 0; z < k; z++) { long[][] wk = new long[k + 1][k + 1]; for (int i = 0; i <= z; i++) { for (int j = 0; j <= z; j++) { 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 <= z + 1; i++) { for (int j = 0; j <= z + 1; j++) { if (i == j + l) { x += wk[i][j]; wk[i][j] = 0; } if (j == i + l) { y += wk[i][j]; wk[i][j] = 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; } }