N,M,K = map(int,input().split()) L = list(input().split()) op = L[0] B = list(map(int, L[1:])) S = sum(B) A = list(int(input()) for _ in range(N)) ans = 0 for i in range(N): if op == '+': ans += (A[i] * M) + S else: ans += A[i] * S ans %= K print(ans)