mod = 10**6 + 3 # Read S_counts s_counts = list(map(int, input().split())) t = input().strip() # Generate T_compact t_compact = [] prev_char = None for c in t: if c != prev_char: t_compact.append(c) prev_char = c k_dict = {} for c in t_compact: if c in k_dict: k_dict[c] += 1 else: k_dict[c] = 1 # Check validity: each c in k_dict must have S_counts >= k_dict[c] valid = True for c in k_dict: idx = ord(c) - ord('a') if s_counts[idx] < k_dict[c]: valid = False break if not valid: print(0) exit() # Calculate the maximum product ans = 1 for c in k_dict: k = k_dict[c] idx = ord(c) - ord('a') s_total = s_counts[idx] m = s_total - k # m >=0 d, r = divmod(m, k) part1 = pow(d + 1, k - r, mod) part2 = pow(d + 2, r, mod) ans = (ans * part1) % mod ans = (ans * part2) % mod print(ans)