n,m,k = map(int,input().split()) l = list(input().split()) op = l[0] b = l[1:] b = [int(i) for i in b] a = [] for i in range(n): a.append(int(input())) ans = 0 if op == "+": ans = sum(a)*m + sum(b)*n else: ans = sum(a)*sum(b) print(ans%k)