MOD = 10**6 + 3 # Read input S_alpha = list(map(int, input().split())) T = input().strip() # Compress T into groups prev_char = None groups = [] for c in T: if c != prev_char: groups.append(c) prev_char = c # Count the number of groups for each character from collections import defaultdict group_counts = defaultdict(int) for c in groups: group_counts[c] += 1 result = 1 for c in group_counts: k = group_counts[c] idx = ord(c) - ord('a') s = S_alpha[idx] if s < k: print(0) exit() m = s - k base, r = divmod(m, k) a = (base + 2) % MOD b = (base + 1) % MOD term = (pow(a, r, MOD) * pow(b, k - r, MOD)) % MOD result = (result * term) % MOD print(result)