// 制約チェック #line 1 "main.cpp" #include #include #line 2 "lib/prelude.hpp" #ifndef LOCAL #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") #endif #include using namespace std; using ll = long long; #define rep2(i, m, n) for (auto i = (m); i < (n); i++) #define rep(i, n) rep2(i, 0, n) #define repr2(i, m, n) for (auto i = (n); i-- > (m);) #define repr(i, n) repr2(i, 0, n) #define all(x) begin(x), end(x) #line 5 "main.cpp" using mint = atcoder::modint998244353; int poly_deg = -1; vector add(vector a, vector b) { int n = max(a.size(), b.size()); vector res(n); rep(i, n) res[i] = (i < a.size() ? a[i] : 0) + (i < b.size() ? b[i] : 0); return res; } vector mul(mint r, vector a) { for (auto& e : a) e *= r; return a; } vector diff(vector a) { rep(i, a.size() - 1) a[i] = a[i + 1] * (i + 1); a.pop_back(); return a; } vector integr(vector a) { // a.push_back(0); repr(i, a.size() - 1) a[i + 1] = a[i] / (i + 1); a[0] = 0; return a; } vector conv(vector a, vector b, int deg = poly_deg) { if (deg != -1) a.resize(min(a.size(), deg)), b.resize(min(b.size(), deg)); auto f = convolution(a, b); if (deg != -1) f.resize(deg); return f; } vector inv(vector f, int deg = poly_deg) { assert(f[0] != 0); vector g = {f[0].inv()}; for (int m = 1; m < deg; m *= 2) { auto h = conv(f, g, m * 2); fill(h.begin(), h.begin() + m, 0); auto hg = conv(h, g, m * 2); rep(i, m * 2) hg[i] = -hg[i]; g.insert(g.end(), hg.begin() + m, hg.end()); } g.resize(deg); return g; } vector exp(vector h, int deg = poly_deg) { assert(h[0] == 0); int n = 1 << atcoder::internal::ceil_pow2(deg); h.resize(n); vector f = {1}, g = {1}; vector q(h.size() - 1); rep(i, q.size()) q[i] = h[i + 1] * (i + 1); for (int m = 1; m < n; m *= 2) { auto fgg = conv(conv(f, g, m), g, m); g.resize(m); rep(i, m) g[i] = g[i] * 2 - fgg[i]; auto fq = conv(f, {q.begin(), q.begin() + m - 1}, m * 2 - 1); rep(i, fq.size()) fq[i] = -fq[i] + (i < f.size() - 1 ? f[i + 1] * (i + 1) : 0); auto w = conv(g, fq, m * 2 - 1); rep(i, m - 1) w[i] += q[i]; w.push_back(0); repr(i, m * 2 - 1) w[i + 1] = h[i + 1] - w[i] / (i + 1); w[0] = h[0]; auto fw = conv(f, w, m * 2); f.resize(m * 2); rep(i, m * 2) f[i] += fw[i]; } f.resize(deg); return f; } vector taylor_shift(vector a, int c) { int n = a.size(); vector fact(n); fact[0] = 1; rep(i, n - 1) a[i + 1] *= fact[i + 1] = fact[i] * (i + 1); reverse(all(a)); a = conv(move(a), exp(vector{0, c}, n), n); a.resize(n); reverse(all(a)); rep(i, n) a[i] /= fact[i]; return a; } struct ratio_t { vector numer, denom; }; ratio_t total(vector qs) { int n = qs.size(); qs.resize(n * 2); move(qs.begin(), qs.begin() + n, qs.begin() + n); repr2(i, 1, n) qs[i] = ratio_t{add(conv(qs[i * 2].numer, qs[i * 2 + 1].denom, -1), conv(qs[i * 2].denom, qs[i * 2 + 1].numer, -1)), conv(qs[i * 2].denom, qs[i * 2 + 1].denom, -1)}; return qs[1]; } vector eval(ratio_t q, int deg = poly_deg) { return conv(move(q.numer), inv(move(q.denom), deg), deg); } int n, m, a[100000], b[100000], c[100000]; int main() { scanf("%d%d", &n, &m); assert(1 <= n && n <= 100000); assert(1 <= m && m <= 100000); rep(i, n) scanf("%d%d%d", a + i, b + i, c + i), assert(1 <= a[i] && a[i] <= 998244352), assert(1 <= b[i] && b[i] <= 998244352), assert(1 <= c[i] && c[i] <= 998244352); string s; assert(!(cin >> s)); poly_deg = m+1; mint ap = 1; rep(i, n) ap *= mint(a[i]).pow(c[i]); vector summands(n); rep(i, n) summands[i] = ratio_t{{mint(1) * c[i] * b[i] / a[i]}, {1, mint(1) * b[i] / a[i]}}; auto f = mul(ap, exp(integr(eval(total(summands))))); f = taylor_shift(move(f), -1); summands.resize(m + 1); rep(i, m + 1) summands[i] = ratio_t{{f[i]}, {1, -i}}; f = eval(total(summands)); rep2(k, 1, m+1) printf("%d\n", f[k].val()); }