MOD = 10**6 + 3 # Read input s_alpha = list(map(int, input().split())) t = input().strip() # Process T into its connected components t_comp = [] prev_char = None for char in t: if char != prev_char: t_comp.append(char) prev_char = char # Count the frequency of each character in t_comp from collections import defaultdict char_count = defaultdict(int) for c in t_comp: char_count[c] += 1 # Check if any character's count exceeds the available S_alpha for c in char_count: idx = ord(c) - ord('a') if s_alpha[idx] < char_count[c]: print(0) exit() # Calculate the product of maximum possible terms result = 1 for c in char_count: idx = ord(c) - ord('a') k = char_count[c] s = s_alpha[idx] m = s // k r = s % k term = (pow(m + 1, r, MOD) * pow(m, k - r, MOD)) % MOD result = (result * term) % MOD print(result)