MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys input = sys.stdin.readline sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from bisect import bisect_left,bisect_right from collections import deque def main(): n,m,k = map(int,input().split()) l = input().split() a = [int(input()) for _ in range(n)] if l[0] == '+': b = [int(l[i]) for i in range(1,m + 1)] ans = 0 for i in range(n): ans += m * a[i] ans %= k for i in range(m): ans += n * b[i] ans %= k print(ans) else: b = sum([int(l[i]) for i in range(1,m + 1)]) ans = 0 for i in range(n): ans += a[i] * b ans %= k print(ans) if __name__ =='__main__': main()