import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; class Main { class State implements Comparable { long a, b; int id; public State(long a_, long b_, int id_) { a = a_; b = b_; id = id_; } void inc() { long x = a - 1; long y = a - b; a = a + 1; b = a - y; } @Override public int compareTo(State o) { return -Long.compare(a * o.b, o.a * b); } } final long MOD = 1_000_000 + 3; long[] fac = new long[(int) MOD]; long[] invfac = new long[(int) MOD]; long[] inv = new long[(int) MOD]; { fac[0] = invfac[0] = fac[1] = invfac[1] = inv[1] = 1; for (int i = 2; i < MOD; ++i) { fac[i] = i * fac[i - 1] % MOD; inv[i] = MOD - inv[(int) MOD % i] * (MOD / i) % MOD; invfac[i] = inv[i] * invfac[i - 1] % MOD; } } long comb(long n, long k) { long ret = 1; while (n > 0 || k > 0) { if (n % MOD < k % MOD) return 0; ret = ret * comb((int) (n % MOD), (int) (k % MOD)) % MOD; n /= MOD; k /= MOD; } return ret; } long comb(int n, int k) { return fac[n] * invfac[k] % MOD * invfac[n - k] % MOD; } long f(ArrayList list, long s) { long res = s; long all = 0; for (long v : list) { all += v; } if (all == s) return 1; if (all > s) return 0; if (list.size() == 0) return 1; PriorityQueue pq = new PriorityQueue<>(); long[] cnt = new long[list.size()]; for (int i = 0; i < list.size(); ++i) { long y = (list.get(i) * s / all) - 1; y = Math.max(y, list.get(i)); res -= y; pq.add(new State(y + 1, y + 1 - list.get(i), i)); cnt[i] = y; } while (res > 0) { State state = pq.poll(); cnt[state.id]++; --res; state.inc(); pq.add(state); } long ret = 1; for (int i = 0; i < cnt.length; ++i) { ret = ret * comb(cnt[i], list.get(i)) % MOD; } return ret; } void run() { Scanner sc = new Scanner(System.in); long[] s = new long[26]; for (int i = 0; i < 26; ++i) { s[i] = sc.nextLong(); } String T = sc.next(); ArrayList[] list = new ArrayList[26]; for (int i = 0; i < list.length; ++i) list[i] = new ArrayList(); for (int i = 0; i < T.length(); ++i) { long c = 1; while (i + 1 < T.length() && T.charAt(i) == T.charAt(i + 1)) { ++c; ++i; } list[T.charAt(i) - 'a'].add(c); } long ret = 1; for (int i = 0; i < 26; ++i) { ret = ret * f(list[i], s[i]) % MOD; } System.out.println(ret); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } public static void main(String[] args) { new Main().run(); } }