n, m, s = map(int, input().split()) x = input().split() j = 1 for i in range(len(x) - 1): x[j] = (int(x[j])) % s j += 1 y = [(int(input())) % s for i in range(n)] total = 0 if x[0] == "+": total = m * sum(y) + n * sum(x[1:]) else: total = sum(x[1:]) * sum(y) print(total % s)