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