import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,k=map(int,input().split())
O=[str(i) for i in input().split()]
A=[int(input()) for _ in range(n)]
op=O[0]
B=[]
for i in range(m):
  B.append(int(O[i+1]))
a=sum(A)%k
b=sum(B)%k
if op=="+":
  ans=n*b+m*a
else:
  ans=a*b
print(ans%k)