N,M,K=map(int,input().split()) A=[] B=[i for i in input().split()] C=0 a=0 b=0 for i in range(N): t=int(input()) A.append(t) if B[0]=="+": for i in range(N): a+=A[i] for j in range(1,M+1): b+=int(B[j]) C=(M*a)+(N*b) elif B[0]=="*": for i in range(N): a += A[i] for j in range(1, M + 1): b += int(B[j]) C=a*b print(C%K)