#include int main(int argc, char const* argv[]) { long N, M, K; scanf("%ld %ld %ld", &N, &M, &K); char op; scanf(" %c", &op); long B[M]; for (int i = 0; i < M; i++) { scanf("%ld", &B[i]); } long int A[N]; for (int i = 0; i < N; i++) { scanf("%ld", &A[i]); } long sum = 0; switch (op) { case '+': for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { sum += A[i] + B[j]; } } break; default: for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { sum += A[i] * B[j]; } } break; } printf("%ld", sum % K); }