N,M,K=map(int,input().split()) B=list(input().split()) A=[int(input()) for i in range(N)] if B[0]=="+": print((sum(A)*M+sum(list(map(int,B[1:])))*N)%K) else: print(sum(A)*sum(list(map(int,B[1:])))%K)