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