#include using namespace std; const long long MOD = 1000000000000000009; struct lazy_segment_tree{ int N; vector sz; vector> cnt, sum; vector lazy_color, lazy_cnt; lazy_segment_tree(vector &A){ int N2 = A.size(); N = 1; while (N < N2){ N *= 2; } sz = vector(N * 2 - 1, 0); for (int i = 0; i < N2; i++){ sz[N - 1 + i] = A[i]; } for (int i = N - 2; i >= 0; i--){ sz[i] = sz[i * 2 + 1] + sz[i * 2 + 2]; } cnt = vector>(N * 2 - 1); sum = vector>(N * 2 - 1); for (int i = 0; i < N * 2 - 1; i++){ for (int j = 0; j < 5; j++){ cnt[i][j] = 0; sum[i][j] = 0; } } lazy_color = vector(N * 2 - 1, -1); lazy_cnt = vector(N * 2 - 1, 0); } void push(int i){ if (lazy_color[i] != -1){ if (i < N - 1){ if (lazy_color[i * 2 + 1] != lazy_color[i]){ lazy_color[i * 2 + 1] = lazy_color[i]; lazy_cnt[i * 2 + 1] = 0; } lazy_cnt[i * 2 + 1] += lazy_cnt[i]; if (lazy_color[i * 2 + 2] != lazy_color[i]){ lazy_color[i * 2 + 2] = lazy_color[i]; lazy_cnt[i * 2 + 2] = 0; } lazy_cnt[i * 2 + 2] += lazy_cnt[i]; } cnt[i][lazy_color[i]] = sz[i]; sum[i][lazy_color[i]] += sz[i] * lazy_cnt[i]; for (int j = 0; j < 5; j++){ if (j != lazy_color[i]){ cnt[i][j] = 0; sum[i][j] = 0; } } lazy_color[i] = -1; lazy_cnt[i] = 0; } } void range_apply(int L, int R, int x, int i, int l, int r){ push(i); if (r <= L || R <= l){ } else if (L <= l && r <= R){ lazy_color[i] = x; lazy_cnt[i] = 1; push(i); } else { int m = (l + r) / 2; range_apply(L, R, x, i * 2 + 1, l, m); range_apply(L, R, x, i * 2 + 2, m, r); for (int j = 0; j < 5; j++){ cnt[i][j] = cnt[i * 2 + 1][j] + cnt[i * 2 + 2][j]; sum[i][j] = sum[i * 2 + 1][j] + sum[i * 2 + 2][j]; } } } void range_apply(int L, int R, int x){ range_apply(L, R, x, 0, 0, N); } array range_sum(int L, int R, int i, int l, int r){ if (r <= L || R <= l){ array res; for (int i = 0; i < 5; i++){ res[i] = 0; } return res; } else if (L <= l && r <= R){ push(i); return sum[i]; } else { push(i); int m = (l + r) / 2; array A = range_sum(L, R, i * 2 + 1, l, m); array B = range_sum(L, R, i * 2 + 2, m, r); for (int i = 0; i < 5; i++){ A[i] += B[i]; } return A; } } array range_sum(int L, int R){ return range_sum(L, R, 0, 0, N); } array all_sum(){ push(0); return sum[0]; } }; int main(){ long long N; cin >> N; int Q; cin >> Q; vector x(Q); vector l(Q), r(Q); for (int i = 0; i < Q; i++){ cin >> x[i] >> l[i] >> r[i]; r[i]++; } vector X; X.push_back(0); X.push_back(N); for (int i = 0; i < Q; i++){ X.push_back(l[i]); X.push_back(r[i]); } sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end()); int cnt = X.size(); for (int i = 0; i < Q; i++){ l[i] = lower_bound(X.begin(), X.end(), l[i]) - X.begin(); r[i] = lower_bound(X.begin(), X.end(), r[i]) - X.begin(); } vector w(cnt - 1); for (int i = 0; i < cnt - 1; i++){ w[i] = X[i + 1] - X[i]; } lazy_segment_tree ST(w); array sum; for (int i = 0; i < 5; i++){ sum[i] = 0; } for (int i = 0; i < Q; i++){ if (x[i] == 0){ array res = ST.range_sum(l[i], r[i]); long long mx = 0; for (int j = 0; j < 5; j++){ mx = max(mx, res[j]); } int mxcnt = 0; for (int j = 0; j < 5; j++){ if (res[j] == mx){ mxcnt++; } } if (mxcnt == 1){ for (int j = 0; j < 5; j++){ if (res[j] == mx){ sum[j] += res[j]; sum[j] %= MOD; } } } } if (x[i] == 1){ ST.range_apply(l[i], r[i], 0); } if (x[i] == 2){ ST.range_apply(l[i], r[i], 1); } if (x[i] == 3){ ST.range_apply(l[i], r[i], 2); } if (x[i] == 4){ ST.range_apply(l[i], r[i], 3); } if (x[i] == 5){ ST.range_apply(l[i], r[i], 4); } } array res = ST.all_sum(); for (int i = 0; i < 5; i++){ sum[i] += res[i]; sum[i] %= MOD; } for (int i = 0; i < 5; i++){ cout << sum[i]; if (i < 4){ cout << ' '; } } cout << endl; }