//https://ncode.syosetu.com/n4830bu/255/ #include "atcoder/all" #include using namespace atcoder; using namespace std; using ll = long long; const ll mod = 1000000000000000009; struct S { ll maine, len; }; S op(S a, S b) { return {a.maine + b.maine, a.len + b.len}; } S e() { return {0, 0}; } struct F { ll book; bool zero; }; S mapping(F f, S x) { (x.maine += f.book * x.len) *= !f.zero; return x; } F composition(F f, F g) { if (g.zero || f.zero) return {0, true}; f.book += g.book; return f; } F id() { return {0, false}; } int main() { ll N; int Q; cin >> N >> Q; vector X(Q); vector L(Q), R(Q); for (int i = 0; i < Q; i++) { cin >> X[i] >> L[i] >> R[i]; X[i]--; R[i]++; } vector compress{0, N}; compress.insert(compress.end(), L.begin(), L.end()); compress.insert(compress.end(), R.begin(), R.end()); sort(compress.begin(), compress.end()); compress.erase(unique(begin(compress), end(compress)), end(compress)); auto idx = [&](ll x) { return lower_bound(compress.begin(), compress.end(), x) - compress.begin(); }; int M = compress.size(); vector initial(M - 1); for (int i = 0; i < M - 1; i++) { initial[i] = {0, compress[i + 1] - compress[i]}; } vector segs(5, lazy_segtree(initial)); vector bonus(5); for (int i = 0; i < Q; i++) { int x = X[i]; ll l = L[i], r = R[i]; int l_idx = idx(l), r_idx = idx(r); if (x >= 0) { for (int y = 0; y < 5; y++) { if (x == y) continue; segs[y].apply(l_idx, r_idx, {0, true}); } segs[x].apply(l_idx, r_idx, {1, false}); } else { vector scores(5); for (int x = 0; x < 5; x++) { scores[x] = segs[x].prod(l_idx, r_idx).maine; } int idx_max = max_element(scores.begin(), scores.end()) - scores.begin(); int cnt = 0; for (int x = 0; x < 5; x++) { cnt += scores[x] == scores[idx_max]; } if (cnt == 1) (bonus[idx_max] += scores[idx_max]) %= mod; } } for (int x = 0; x < 5; x++) { cout << (segs[x].all_prod().maine + bonus[x]) % mod << " \n"[x == 4]; } }