n, m, s = map(int, input().split()) x = input().split() j = 1 for i in range(len(x) - 1): x[j] = int(x[j]) j += 1 y = [int(input()) for i in range(n)] sum = 0 if x[0] == "+": for i in y: for j in range(len(x) - 1): sum += i + x[j + 1] else: for i in y: ax = "" for j in range(len(x) - 1): sum += i * x[j + 1] print(sum % s)