import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ n,m,k = map(int, input().split()) op, *B = input().split() B = list(map(int, B)) A = [int(input()) for i in range(n)] if op == "+": ans = sum(A)*m + sum(B)*n ans %= k else: sum_B = sum(B) sum_A = sum(A) ans = sum_A*sum_B ans %= k print(ans)