#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np # %% N, M, MOD = map(int, readline().split()) op = read(1).decode() BA = np.array(read().split(), np.int64) # %% B = BA[:M] A = BA[M:] # %% def solve_add(B, A): SA = A.sum() % MOD SB = B.sum() % MOD return (SA * len(B) + SB * len(A)) % MOD # %% def solve_mult(B, A): SA = A.sum() % MOD SB = B.sum() % MOD return SA * SB % MOD # %% answer = solve_add(B, A) if op == '+' else solve_mult(B, A) print(answer)