#include #include #include #include using namespace std; #ifndef __DEBUG__ #define dbg(...) 42 #endif template using mpq = priority_queue, greater>; using ll = long long; using pii = pair; using pll = pair; using vl = vector; using vi = vector; using mint = atcoder::modint998244353; using atcoder::lazy_segtree; using S = mint; struct F { mint prob; mint val; }; S op(S a, S b) { return a + b; } S e() { return 0; } S mapping(F f, S a) { return (1 - f.prob) * a + f.prob * f.val; } F composition(F f, F g) { if (f.prob == 0) return g; if (g.prob == 0) return f; mint prob = 1 - (1 - f.prob) * (1 - g.prob); // mint val = f.prob * (1 - g.prob) * f.val + g.prob * g.val; mint punion = f.prob * g.prob; mint pall = f.prob + g.prob - punion; mint val = (f.prob - punion) / pall * f.val + g.prob / pall * g.val; return {prob, val}; } F id() { return {0, 0}; } int main(int argc, char **argv) { ll n, m; cin >> n >> m; vector mv(n); int v; for (auto &x : mv) cin >> v, x = v; lazy_segtree seg(mv); for (int i = 0, l, r, x; i < m; ++i) { cin >> l >> r >> x; l -= 1; mint d = r - l; seg.apply(l, r, F{1 / d, mint(x)}); } for (int i = 0; i < n; ++i) cout << seg.get(i).val() << " \n"[i == n - 1]; return 0; };