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)] sum = 0 if x[0] == "+": sum = m * sum(y) + n * sum(x[1:]) else: sum = sum(x[1:]) * sum(y) print(sum % s)