#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

template<class T> class LazySegmentTree {
    public:
    size_t n;       // 葉の数
    vector<T> data; // データ
    vector<T> lazy; // 遅延評価用
    T unit;         // 単位元
    T def;          // 初期値
    T lazy_def;     // 遅延評価用初期値
    function<T(T, size_t, size_t, T)> update_func;      // 更新で使う処理
    function<T(T, T)> find_func;        // クエリで使う処理
    function<T(T, T)> lazy_prop_func;   // 遅延評価用の値を子ノードに伝播させる処理

    LazySegmentTree(
        size_t _n, T _unit, T _def, T _lazy_def,  
        function<T(T, size_t, size_t, T)> _update_func, 
        function<T(T, T)> _find_func, 
        function<T(T, T)> _lazy_prop_func
        ) : unit(_unit), def(_def), lazy_def(_lazy_def), update_func(_update_func), find_func(_find_func), lazy_prop_func(_lazy_prop_func) {
        // 2のべき乗にする
        n = 1;
        while(n < _n) n <<= 1;
        data = vector<T>(2*n-1, _def);
        lazy = vector<T>(2*n-1, _lazy_def);
    }

    void eval(size_t k, size_t kl, size_t kr) {
        if(lazy[k] == lazy_def) return;
        data[k] = update_func(data[k], kl, kr, lazy[k]);
        if(kr - kl > 1){
            lazy[2*k+1] = lazy_prop_func(lazy[2*k+1], lazy[k]);
            lazy[2*k+2] = lazy_prop_func(lazy[2*k+1], lazy[k]);
        }
        lazy[k] = lazy_def;
    }

    void _update(size_t s, size_t t, size_t k, size_t kl, size_t kr, T x){
        eval(k, kl, kr);

        if(t <= kl || kr <= s) return;
        if(s <= kl && kr <= t) {
            lazy[k] = lazy_prop_func(lazy[k], x);
            eval(k, kl, kr);
        } else {
            size_t kc = (kl+kr)/2;
            _update(s, t, 2*k+1, kl, kc, x);
            _update(s, t, 2*k+2, kc, kr, x);
            data[k] = find_func(data[2*k+1], data[2*k+2]);
        }
    }

    void update(size_t s, size_t t, T x) {
        return _update(s, t, 0, 0, n, x);
    }

    T _find(size_t s, size_t t, size_t k, size_t kl, size_t kr){
        if(kr <= s || t <= kl) return unit;

        eval(k, kl, kr);
        if(s <= kl && kr <= t) return data[k];

        size_t kc = (kl+kr)/2;
        T vl = _find(s, t, 2*k+1, kl, kc);
        T vr = _find(s, t, 2*k+2, kc, kr);
        return find_func(vl, vr);
    }
    
    T find(size_t s, size_t t) {
        return _find(s, t, 0, 0, n);
    }
};

int main() {
    unsigned int n, q, com, s, t; 
    ll x;
    cin >> n >> q;
    LazySegmentTree<ll> tree(
        n, 0LL, 0LL, 1LL << 60, 
        [](ll a, size_t l, size_t r, ll b) { return (r-l) * b; }, 
        [](ll a, ll b) { return a+b; }, 
        [](ll a, ll b) { return b; }
    );

    while(q--) {
        cin >> com;
        if(com) {
            cin >> s >> t;
            cout << tree.find(s, t+1) << endl;
        } else {
            cin >> s >> t >> x;
            tree.update(s, t+1, x);
        }
    }
    
}


Measured memory_bytes: 7068