#include #include #include #include #include #include #include #include #include using mint = atcoder::static_modint<943718401>; // <嘘解法 (WA)> // x = 0 のとき S = \sum_{i = 0}^n (A_i B_i C_0 + A_i B_0 C_i) と計算している。 mint S(const int n, const mint& x, std::vector a, std::vector b, std::vector c) { assert(n == std::ssize(a) - 1 && n == std::ssize(b) - 1 && n == std::ssize(c) - 1); if (x == 0) { mint s = 0; s += std::inner_product(a.begin(), a.end(), b.begin(), mint::raw(0)) * c[0]; s += std::inner_product(a.begin(), a.end(), c.begin(), mint::raw(0)) * b[0]; return s; } const auto MakeWeights = [n](mint base) -> std::vector { base *= base; mint single_exp = 1, double_exp = 1; std::vector weights(n + 1, 1); for (int i = 0; i < n; ++i) { double_exp *= single_exp; single_exp *= base; weights[i + 1] = weights[i] * double_exp; } return weights; }; std::ranges::transform(a, MakeWeights(x), a.begin(), std::multiplies()); const std::vector weights_inv = MakeWeights(x.inv()); std::ranges::transform(b, weights_inv, b.begin(), std::multiplies()); std::ranges::transform(c, weights_inv, c.begin(), std::multiplies()); const std::vector s = atcoder::convolution(b, c); return std::inner_product(a.begin(), a.end(), s.begin(), mint::raw(0)); } int main() { constexpr int kMaxN = 200000; const auto GetMint = []() -> mint { int x; std::cin >> x; assert(0 <= x && x < mint::mod()); return mint::raw(x); }; int n; std::cin >> n; assert(0 <= n && n <= kMaxN); const mint x = GetMint(); std::vector a(n + 1), b(n + 1), c(n + 1); std::ranges::for_each(a, [GetMint](mint& x) -> void { x = GetMint(); }); std::ranges::for_each(b, [GetMint](mint& x) -> void { x = GetMint(); }); std::ranges::for_each(c, [GetMint](mint& x) -> void { x = GetMint(); }); std::cout << S(n, x, a, b, c).val() << '\n'; return 0; }