#include namespace { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic pop using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint1000000007; struct S { int cnt; mint sm; mint f; }; S e() { return { 0, 0, 0 }; } S op(S x, S y) { return { x.cnt + y.cnt, x.sm + y.sm, x.f + y.f }; } struct F { int assign; // ax + bF + c mint a, b, c; }; F id() { return { -1, 1, 0, 0}; } F composition(F f, F g) { if (f.assign != -1) return f; // fa (ga x + gb F + gc) + fb F + fc // fa ga x + (fa gb + fb) F + fa gc + fc return { g.assign, f.a * g.a, f.a * g.b + f.b, f.a * g.c + f.c }; } S mapping(F f, S x) { if (f.assign != -1) x.sm = mint::raw(x.cnt) * f.assign; x.sm = f.a * x.sm + f.b * x.f + f.c * x.cnt; return x; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; vector init_vec(n, {1, 0, 0}); init_vec[0].f = 0; if (n > 1) { init_vec[1].f = 1; for(int i = 2; i < n; i++) init_vec[i].f = init_vec[i-2].f + init_vec[i-1].f; } lazy_segtree seg(init_vec); while(q--) { int q, l, r, k; cin >> q >> l >> r >> k; r++; switch(q) { case 0: { mint ans = k * seg.prod(l, r).sm; cout << ans.val() << '\n'; break; } case 1: { seg.apply(l, r, { k, 1, 0, 0 }); break; } case 2: { seg.apply(l, r, { -1, 1, 0, k }); break; } case 3: { seg.apply(l, r, { -1, k, 0, 0 }); break; } case 4: { seg.apply(l, r, { -1, 1, k, 0 }); break; } } } }