MOD = 10**6 + 3 # Read input s_counts = list(map(int, input().split())) t = input().strip() # Function to compress the string T def compress(s): if not s: return [] compressed = [s[0]] for c in s[1:]: if c != compressed[-1]: compressed.append(c) return compressed C = compress(t) if not C: print(0) exit() from collections import defaultdict # Count occurrences of each character in the compressed T char_counts = defaultdict(int) for c in C: char_counts[c] += 1 # Mapping from character to its available count in S alpha = 'abcdefghijklmnopqrstuvwxyz' S = {alpha[i]: s_counts[i] for i in range(26)} # Check if all characters in compressed T have sufficient count in S valid = True for c in char_counts: required = char_counts[c] if S[c] < required: valid = False break if not valid: print(0) exit() result = 1 # Calculate the product for each character's contribution for c in char_counts: k = char_counts[c] available = S[c] rem = available - k if rem < 0: result = 0 break base = rem // k r = rem % k # Compute (base + 2)^r * (base + 1)^(k - r) mod MOD part1 = pow(base + 2, r, MOD) part2 = pow(base + 1, k - r, MOD) total = (part1 * part2) % MOD result = (result * total) % MOD print(result)