import sys n, m, k = map(int, input().split()) op, *B = input().split() A = list(map(int, sys.stdin)) B = list(map(int, B)) print({"+":(sum(A)*m + n*sum(B)), "*":sum(A)*sum(B)}[op]%k)