// Slower C++ solution:
#include <cstdio>

#include <climits>

#include <algorithm>

using namespace std;



// Abstract Lazy Segment Tree (????±?????±?????????¶?????°???????????¨)

const int SIZE = 1 << 17; // 2^17 = 131072

template<typename T>

struct lazysegtree {

    // ?????????????????????

    T node[2*SIZE], lazy[2*SIZE], I;

    bool need_upd[2*SIZE];



    // ????????¬????????§??? (update, query ??? 2 ???????????????)

    // update function ??????????????????????????¢????????????

    // upd_f(X, Y, l, r) -> ????????? [l, r) ??§???????????????????????? X ??? Y ????????????

    // lazy ???????????? update ??¨??????????????? 1 ??????????????¨?????°?????????

    T (*upd_f)(T, T, int, int), (*qry_f)(T, T);



    // ???????????¨?????????????????????????????¨?????? node ??¨ lazy ??????????????§?????????

    lazysegtree(T (*op1)(T, T, int, int), T (*op2)(T, T), T X) {

        upd_f = op1;

        qry_f = op2;

        I = X;

        fill(lazy, lazy+2*SIZE, I);

        fill(node, node+2*SIZE, I);

        fill(need_upd, need_upd+2*SIZE, false);

    }



    void lazy_eval(int k, int l, int r) {

        if(!need_upd[k]) return;

        node[k] = upd_f(node[k], lazy[k], l, r);

        if(r - l > 1) {

            lazy[2*k+1] = upd_f(lazy[2*k+1], lazy[k], 0, 1);

            lazy[2*k+2] = upd_f(lazy[2*k+2], lazy[k], 0, 1);

            need_upd[2*k+1] = need_upd[2*k+2] = true;

        }

        lazy[k] = I;

        need_upd[k] = false;

    }



    // ???????????? [a, b) ??????????????? val ??????????????????

    // (upd_f ?????¨????????????)

    void update(int a, int b, T val, int l=0, int r=SIZE, int k=0) {

        lazy_eval(k, l, r);

        if(b <= l || r <= a) return;

        if(a <= l && r <= b) {

            lazy[k] = upd_f(lazy[k], val, 0, 1);

            need_upd[k] = true;

            lazy_eval(k, l, r);

        }

        else {

            int mid = (l + r) / 2;

            update(a, b, val, l, mid, 2*k+1);

            update(a, b, val, mid, r, 2*k+2);

            node[k] = qry_f(node[2*k+1], node[2*k+2]);

        }

    }



    // ???????????? [a, b) ?????????????????¨???????????????

    // (qry_f ?????¨????????????)

    T query(int a, int b, int l=0, int r=SIZE, int k=0) {

        lazy_eval(k, l, r);

        if(b <= l || r <= a) return I;

        if(a <= l && r <= b) return node[k];

        int mid = (l + r) / 2;

        T vl = query(a, b, l, mid, 2*k+1);

        T vr = query(a, b, mid, r, 2*k+2);

        return qry_f(vl, vr);

    }

};



// [[???????????????]]

// update ??¨??¨ query ??¨?????¢??°??¨????????? (??¢??°????????????????????????????????????????????????) ?????¨???????????£?¨???????

// ??????????????¨???update ??¨?????¢??°??? upd ??§???query ??¨?????¢??°??? fnd ??§??????????????? INT_MAX



typedef long long int ll;

ll upd(ll a, ll b, int l, int r) {return a + (r - l) * b;}

ll fnd(ll a, ll b) {return a + b;}

lazysegtree<ll> seg(upd, fnd, 0LL);



int main() {

    int N, Q; scanf("%d%d", &N, &Q);

    while(Q--) {

        int q; scanf("%d", &q);

        if(q == 0) {

            int s, t, x; scanf("%d%d%d", &s, &t, &x); s--;

            seg.update(s, t, x);

        }

        else {

            int s, t; scanf("%d%d", &s, &t); s--;

            printf("%lld\n", seg.query(s, t));

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.700481217918618x):
#include <vector>

#include <functional>

#include <algorithm>

#include <iostream>

#include <climits>

using namespace std;



template <typename MonoidType, typename OperatorType>

struct LazySegmentTree {

    using MMtoM = function< MonoidType(MonoidType, MonoidType) >;

    using OOtoO = function< OperatorType(OperatorType, OperatorType) >;

    using MOtoM = function< MonoidType(MonoidType, OperatorType) >;

    using OItoO = function< OperatorType(OperatorType, int) >;



    // node, lazy, update flag (for lazy), identity element

    int n;

    vector<MonoidType> node;

    vector<OperatorType> lazy;

    vector<bool> need_update;

    MonoidType E0;

    OperatorType E1;



    // update / combine / lazy / accumulate function

    OOtoO upd_f;

    MMtoM cmb_f;

    MOtoM lzy_f;

    OItoO acc_f;



    void build(int m, vector<MonoidType> v = vector<MonoidType>()) {

        if(v != vector<MonoidType>()) m = v.size();

        n = 1; while(n < m) n *= 2;



        node = vector<MonoidType>(2*n-1, E0);

        lazy = vector<OperatorType>(2*n-1, E1);

        need_update = vector<bool>(2*n-1, false);

        if(v != vector<MonoidType>()) {

            for(int i=0; i<m; i++) {

                node[n-1+i] = v[i];

            }

            for(int i=n-2; i>=0; i--) {

                node[i] = cmb_f(node[2*i+1], node[2*i+2]);

            }

        }

    }



    // initialize

    LazySegmentTree() {}

    LazySegmentTree(int n_, MonoidType E0_, OperatorType E1_,

                    OOtoO upd_f_, MMtoM cmb_f_, MOtoM lzy_f_, OItoO acc_f_,

                    vector<MonoidType> v = vector<MonoidType>()) :

        E0(E0_), E1(E1_),

        upd_f(upd_f_), cmb_f(cmb_f_), lzy_f(lzy_f_), acc_f(acc_f_) {

        build(n_, v);

    }



    void eval(int k, int l, int r) {

        if(!need_update[k]) return;

        node[k] = upd_f(node[k], acc_f(lazy[k], r - l));

        if(r - l > 1) {

            lazy[2*k+1] = lzy_f(lazy[2*k+1], lazy[k]);

            lazy[2*k+2] = lzy_f(lazy[2*k+2], lazy[k]);

            need_update[2*k+1] = need_update[2*k+2] = true;

        }

        lazy[k] = E1;

        need_update[k] = false;

    }



    void update(int a, int b, OperatorType x, int l, int r, int k) {

        eval(k, l, r);

        if(b <= l or  r <= a) return;

        if(a <= l and r <= b) {

            lazy[k] = lzy_f(lazy[k], x);

            need_update[k] = true;

            eval(k, l, r);

        }

        else {

            int mid = (l + r) / 2;

            update(a, b, x, l, mid, 2*k+1);

            update(a, b, x, mid, r, 2*k+2);

            node[k] = cmb_f(node[2*k+1], node[2*k+2]);

        }

    }



    MonoidType query(int a, int b, int l, int r, int k) {

        if(b <= l or  r <= a) return E0;

        eval(k, l, r);

        if(a <= l and r <= b) return node[k];

        int mid = (l + r) / 2;

        MonoidType vl = query(a, b, l, mid, 2*k+1);

        MonoidType vr = query(a, b, mid, r, 2*k+2);

        return cmb_f(vl, vr);

    }



    // update [a, b)-th element (applied value, x)

    void update(int a, int b, OperatorType x) {

        update(a, b, x, 0, n, 0);

    }



    // range query for [a, b)

    MonoidType query(int a, int b) {

        return query(a, b, 0, n, 0);

    }



    void dump() {

        fprintf(stderr, "[lazy]\n");

        for(int i=0; i<2*n-1; i++) {

            if(i == n-1) fprintf(stderr, "xxx ");

            if(lazy[i] == E1) fprintf(stderr, "E ");

            else fprintf(stderr, "%d ", lazy[i]);

        }

        fprintf(stderr, "\n");



        fprintf(stderr, "[node]\n");

        for(int i=0; i<2*n-1; i++) {

            if(i == n-1) fprintf(stderr, "xxx ");

            if(node[i] == E0) fprintf(stderr, "E ");

            else fprintf(stderr, "%d ", node[i]);

        }

        fprintf(stderr, "\n");

    }

};



void DSL_2_D() {

    int N, Q; cin >> N >> Q;

    LazySegmentTree<int, int> seg(N, INT_MAX, INT_MAX,

                                  [](int a, int b) { return b;         },  // upd

                                  [](int a, int b) { return min(a, b); },  // cmb

                                  [](int a, int b) { return b;         },  // lzy

                                  [](int a, int x) { return a;         }); // acc

    

    int indexed = 0;

    for(int i=0; i<Q; i++) {

        int query_type; cin >> query_type;

        if(query_type == 0) {

            int s, t, x; cin >> s >> t >> x; t++;

            s -= indexed, t -= indexed;

            seg.update(s, t, x);

        }

        if(query_type == 1) {

            int s; cin >> s;

            s -= indexed;

            cout << seg.query(s, s+1) << endl;

        }

        // seg.dump();

    }

}



void DSL_2_E() {

    int N, Q; cin >> N >> Q;

    LazySegmentTree<int, int> seg(N, 0, 0,

                                  [](int a, int b) { return a + b; },  // upd

                                  [](int a, int b) { return a + b; },  // cmb

                                  [](int a, int b) { return a + b; },  // lzy

                                  [](int a, int x) { return a * x; }); // acc

    

    int indexed = 1;

    for(int i=0; i<Q; i++) {

        int query_type; cin >> query_type;

        if(query_type == 0) {

            int s, t, x; cin >> s >> t >> x; t++;

            s -= indexed, t -= indexed;

            seg.update(s, t, x);

        }

        if(query_type == 1) {

            int s; cin >> s;

            s -= indexed;

            cout << seg.query(s, s+1) << endl;

        }

        // seg.dump();

    }    

}



void DSL_2_F() {

    int N, Q; cin >> N >> Q;

    LazySegmentTree<int, int> seg(N, INT_MAX, 0,

                                  [](int a, int b) { return b;         },  // upd

                                  [](int a, int b) { return min(a, b); },  // cmb

                                  [](int a, int b) { return b;         },  // lzy

                                  [](int a, int x) { return a;         }); // acc

    

    int indexed = 0;

    for(int i=0; i<Q; i++) {

        int query_type; cin >> query_type;

        if(query_type == 0) {

            int s, t, x; cin >> s >> t >> x; t++;

            s -= indexed, t -= indexed;

            seg.update(s, t, x);

        }

        if(query_type == 1) {

            int s, t; cin >> s >> t; t++;

            s -= indexed; t -= indexed;

            cout << seg.query(s, t) << endl;

        }

        // seg.dump();

    }    

}





void DSL_2_G() {

    int N, Q; cin >> N >> Q;

    using ll = long long int;

    LazySegmentTree<ll, ll> seg(N, 0, 0,

                                  [](ll a, ll  b) { return a + b; },  // upd

                                  [](ll a, ll  b) { return a + b; },  // cmb

                                  [](ll a, ll  b) { return a + b; },  // lzy

                                  [](ll a, int x) { return a * x; }); // acc

    

    int indexed = 1;

    for(int i=0; i<Q; i++) {

        int query_type; cin >> query_type;

        if(query_type == 0) {

            int s, t, x; cin >> s >> t >> x; t++;

            s -= indexed, t -= indexed;

            seg.update(s, t, x);

        }

        if(query_type == 1) {

            int s, t; cin >> s >> t; t++;

            s -= indexed; t -= indexed;

            cout << seg.query(s, t) << endl;

        }

        // seg.dump();

    }    

}



int main() {

    // DSL_2_D();

    // DSL_2_E();

    // DSL_2_F();

    DSL_2_G();

    return 0;

}