#include #include #include int main() { uint32_t N, M, K; std::cin >> N >> M >> K; std::string op; std::cin >> op; std::vector bs{}; for (uint32_t i = 0; i < M; ++i) { uint32_t b; std::cin >> b; bs.push_back(b); } std::vector as{}; for (uint32_t i = 0; i < N; ++i) { uint32_t a; std::cin >> a; as.push_back(a); } uint32_t result = 0; for (auto a : as) { for (auto b : bs) { result += op == "+" ? (a + b) : (a * b); result %= K; } } std::cout << result % K << std::endl; }