N, M, K = [int(x) for x in input().split()] C = [x for x in input().split()] B = [int(x) for x in C[1:]] A = [int(input()) for _ in range(N)] ans = 0 for j in range(N): for i in range(M): if C[0] == '+': ans += A[j] + B[i] ans %= K else: ans += A[j] * B[i] ans %= K print(ans % K)