N, M, K = map(int, input().split()) op, *B = input().split() A = sum([int(input()) for _ in range(N)]) B = sum(list(map(int, B))) print((A*B) % K if op == '*' else (M*A+N*B) % K)