#yuki987 n,m,k=map(int,raw_input().split()) op=raw_input().split() b=[] for i in range(1,len(op)): b.append(int(op[i])) a=[] for i in range(n): a.append(int(raw_input())) if op[0]=='+': print (sum(a)*m+sum(b)*n)%k else: print (sum(a)*sum(b))%k