n, m, k = map(int, input().split()) op, *b = input().split() b = [int(x) for x in b] a = [int(input()) for _ in range(n)] res = 0 if op == '+': for be in b: res += be * n for ae in a: res += ae * m else: res = 0 aa = sum(a) bb = sum(b) #for ae in a: #res += ae * bb res = aa * bb print(res % k)