Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:

* $update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.
* $getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$.



Note that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0.

Constraints

* $1 ≤ n ≤ 100000$
* $1 ≤ q ≤ 100000$
* $0 ≤ s ≤ t < n$
* $-1000 ≤ x ≤ 1000$

Input


$n$ $q$
$query_1$
$query_2$
:
$query_q$


In the first line, $n$ (the number of elements in $A$) and $q$ (the number of queries) are given. Then, $i$-th query $query_i$ is given in the following format:


0 $s$ $t$ $x$


or


1 $s$ $t$


The first digit represents the type of the query. '0' denotes $update(s, t, x)$ and '1' denotes $find(s, t)$.

Output

For each $getSum$ query, print the sum in a line.

Example

Input

6 7
0 1 3 1
0 2 4 -2
1 0 5
1 0 1
0 3 5 3
1 3 4
1 0 5


Output

-5
1
6
8
#include <bits/stdc++.h>
using namespace std;
#define ln '\n'
typedef long long ll;
typedef pair<long long, long long> pll;
///////////////////////////////////////////////////////////////////////////

template<typename T, typename U, typename F, typename G, typename H>
struct LazySegmentTree {
    T unitynode;
    U unitylazy;
    F f;
    G g;
    H h;
    int N;
    int height;
    vector<T> node;
    vector<U> lazy;

    LazySegmentTree(F f, G g, H h, T unitynode, U unitylazy) : f(f), g(g), h(h), unitynode(unitynode), unitylazy(unitylazy) {}

    void init(int sz) {
        N = 1;
        height = 0;
        while (N < sz) {
            N *= 2;
            ++height;
        }
        node.assign(2*N,unitynode);
        lazy.assign(2*N,unitylazy);
    }

    void set(int k, const T &val) {node[k+N] = val;}

    void build() {
        for (int i = N-1; i > 0; --i) {
            node[i] = f(node[i<<1|0],node[i<<1|1]);
        }
    }

    inline T reflect(int k) {
        return lazy[k] == unitylazy ? node[k] : g(node[k],lazy[k]);
    }

    void eval(int k) {
        if (lazy[k] == unitylazy) return;
        if (k < N) {
            lazy[k<<1|0] = h(lazy[k<<1|0],lazy[k]);
            lazy[k<<1|1] = h(lazy[k<<1|1],lazy[k]);
        }
        node[k] = reflect(k);
        lazy[k] = unitylazy;
    }

    inline void recalc(int k) {
        while (k >>= 1) {
            node[k] = f(reflect(k<<1|0),reflect(k<<1|1));
        }
    }

    // [l,r) (0-indexed)
    void update(int l, int r, U val) {
        if (l >= r) return;
        l += N; r += N-1;
        for (int i = height; i > 0; --i) {
            eval(l>>i);
            eval(r>>i);
        }
        int a = l; int b = r++;
        while (l < r) {
            if (l & 1) lazy[l] = h(lazy[l],val), ++l;
            if (r & 1) --r, lazy[r] = h(lazy[r],val);
            l >>= 1; r >>= 1;
        }
        recalc(a);
        recalc(b);
    }

    T get(int l, int r) {
        if (l >= r) return unitynode;
        l += N; r += N-1;
        for (int i = height; i > 0; --i) {
            eval(l>>i);
            eval(r>>i);
        }
        ++r;
        T vl = unitynode, vr = unitynode;
        while (l < r) {
            if (l & 1) vl = f(vl,reflect(l++));
            if (r & 1) vr = f(reflect(--r),vr);
            l >>= 1; r >>= 1;
        }
        return f(vl,vr);
    }

    T operator[](int x) {return reflect(x+N);}
};

/*
example
auto f=[&](int a,int b){return max(a,b);};
const int id = -1e9;
SegmentTree<int, decltype(f)> seg(f,id);
*/

////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,Q; cin >> N >> Q;

    auto f=[](pll a, pll b) {return make_pair(a.first+b.first,a.second+b.second);};
    auto g=[](pll a, ll b) {return make_pair(a.second*b,a.second);};
    auto h=[](ll a, ll b) {return b;};
    pll id1 = make_pair(0,0);
    ll id2 = 1e9;
    LazySegmentTree<pll, ll, decltype(f), decltype(g), decltype(h)> seg(f,g,h,id1,id2);
    seg.init(N);
    for (int i = 0; i < N; ++i) seg.set(i,make_pair(0,1));
    seg.build();

    while (Q--) {
        int com; cin >> com;
        if (com) {
            int s,t; cin >> s >> t;
            cout << seg.get(s,++t).first << ln;
        } else {
            ll s,t,x; cin >> s >> t >> x;
            seg.update(s,++t,x);
        }
    }
}

