MOD = 10**6 + 3 # Read the S_alpha values for each of the 26 letters S_alpha = list(map(int, input().split())) T = input().strip() # Function to compute the runs in T's minimal form def compute_runs(s): runs = [] prev = None for c in s: if c != prev: runs.append(c) prev = c return runs # Get the runs in T's minimal form runs = compute_runs(T) # Count how many runs each character has from collections import defaultdict char_runs = defaultdict(int) for c in runs: char_runs[c] += 1 # Calculate the result result = 1 for char in char_runs: k = char_runs[char] # Get the index in S_alpha idx = ord(char) - ord('a') s = S_alpha[idx] if s < k: print(0) exit() E = s - k a = E // k b = E % k # Calculate contribution: (a+1)^(k - b) * (a+2)^b mod MOD part1 = pow(a + 1, k - b, MOD) part2 = pow(a + 2, b, MOD) contribution = (part1 * part2) % MOD result = (result * contribution) % MOD print(result % MOD)