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[][] 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] * a[c] % mod * sm % mod; wk[i + 1][j + 1] %= mod; wk[i][j] += dp[i][j] * (sum - a[c]) % mod * sm % mod; wk[i][j] %= mod; } else { int c1 = s[p1] - 'a'; wk[i + 1][j] += dp[i][j] * a[c1] % mod * sm % mod; wk[i + 1][j] %= mod; int c2 = t[p2] - 'a'; wk[i][j + 1] += dp[i][j] * a[c2] % mod * sm % mod; wk[i][j + 1] %= mod; wk[i][j] += dp[i][j] * (sum - a[c1] - a[c2]) % mod * sm % mod; wk[i][j] %= mod; } } } for (int i = 0; i <= k; i++) { for (int j = 0; j <= k; 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; } }