from functools import reduce from operator import add from sys import stdin def main(): input = lambda: stdin.readline()[:-1] N, M, K = map(int, input().split()) B = input().split() A = [int(input()) for _ in [0] * N] an = reduce(add, A) % K bm = reduce(add, map(int, B[1:])) % K if B[0] == '+': ans = 0 for a in A: am = (a * M) % K ans = (ans + am + bm) % K else: ans = (an * bm) % K print(ans) main()