n, m, k = map(int, input().split()) op, *b = input().split() b = list(map(int, b)) a = [int(input()) for _ in range(n)] a_sum = sum(a) ans = 0 for eb in b: if op == "*": ans += eb * a_sum else: ans += eb * n + a_sum ans %= k print(ans)