#include #include #include using mint = atcoder::static_modint<943718401>; namespace atcoder { std::istream& operator>>(std::istream& in, mint &a) { long long e; in >> e; a = e; return in; } std::ostream& operator<<(std::ostream& out, const mint &a) { out << a.val(); return out; } } // namespace atcoder mint naive(const int n, const mint x, const std::vector &a, const std::vector &b, const std::vector &c) { mint ans = 0; for (long long i = 0; i <= n; ++i) for (long long j = 0; j <= i; ++j) { long long k = i - j; ans += a[i] * b[j] * c[k] * x.pow(i * j * k); } return ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, x; std::cin >> n >> x; std::vector a(n + 1), b(n + 1), c(n + 1); for (int i = 0, v; i <= n; ++i) std::cin >> v, a[i] = v; for (int i = 0, v; i <= n; ++i) std::cin >> v, b[i] = v; for (int i = 0, v; i <= n; ++i) std::cin >> v, c[i] = v; assert(n <= 5000 or x == 0); std::cout << naive(n, x, a, b, c).val() << std::endl; return 0; }