Problem: 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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

class segment_tree{
    vector<int64_t> val;
    vector<pair<int64_t, int64_t>> op;
    vector<pair<size_t, size_t>> range;

    pair<int64_t, int64_t> ident = {1, 0};
    size_t N, depth;

    inline void merge(size_t target, int64_t alpha, int64_t beta){
        op[target] = {op[target].first * alpha, op[target].second * alpha + beta};
    }
    inline void propagate(size_t target){
        // min, max -> width = 1
        if(op[target] == ident) return;
        val[target] = op[target].first * val[target] + op[target].second * (range[target].second - range[target].first);
        if(target  < N){
            merge(2*target, op[target].first, op[target].second);
            merge(2*target+1, op[target].first, op[target].second);
        }
        op[target] = {1, 0};
    }
    
    inline void eval(int n){
        stack<size_t> stk;
        for(;n>0;n>>=1) stk.push(n);
        while(!stk.empty()){
            propagate(stk.top());
            stk.pop();
        }
    }
    inline void get_target(vector<size_t> &target, size_t left, size_t right, stack<size_t> *refresh=nullptr){
        queue<size_t> partial;
        
        if(left <= 0 && right >= N) target.push_back(1);
        else partial.push(1);

        while(!partial.empty()){
            size_t i = partial.front();
            if(refresh != nullptr) refresh->push(i);
            partial.pop();

            propagate(i);

            if(left <= range[i].first){
                if(right < range[i*2].second) partial.push(i*2);
                else{
                    target.push_back(i*2);
                    if(range[i*2+1].first < right) partial.push(i*2+1);
                }
            }else{
                if(left < range[i*2].second){
                    partial.push(i*2);
                    if(range[i*2+1].second <= right) target.push_back(i*2+1);
                    else if(range[i*2].second < right) partial.push(i*2+1); 
                }else{
                    if(left <= range[i*2+1].first && range[i*2+1].second <= right) target.push_back(i*2+1);
                    else partial.push(i*2+1);
                }
            }
        }
    }
public:
    segment_tree(size_t n){
        for(depth=0;(1ULL<<depth)<n;depth++);
        N = 1ULL<<depth;
        val.reserve(1ULL<<(++depth));
        op.reserve(1ULL<<depth);
        range.reserve(1ULL<<depth);
        for(size_t i=2*N-1;i>0;i--){
            if(i>=N) range[i] = {i-N, i-N+1};
            else range[i] = {range[2*i].first, range[2*i+1].second};
        }
    }
    int64_t operator[](size_t i){
        eval(N+i);
        return val[N+i];
    }
    void operate(int64_t alpha, int64_t beta, size_t left, size_t right){
        if(right <= left) return;

        vector<size_t> target;
        stack<size_t> refresh;
        get_target(target, left, right, &refresh);
        for(auto i : target){
            merge(i, alpha, beta);
            propagate(i);
        }
        while(!refresh.empty()){
            size_t i = refresh.top();
            refresh.pop();
            //min, max -> change
            propagate(i*2);
            propagate(i*2+1);
            val[i] = val[i*2] + val[i*2+1];
        }
    }
    int64_t get_sum(size_t left, size_t right){
        if(right <= left) return 0;
        
        vector<size_t> target;
        get_target(target, left, right);
        int64_t ret = 0;
        for(auto i : target){
            ret += op[i].first * val[i] + op[i].second * (range[i].second - range[i].first);
        }
        return ret;
    }
    void update(int64_t val, size_t pos){
        operate(0, val, pos, pos+1);
    }
    void update(int64_t val, size_t left, size_t right){
        operate(0, val, left, right);
    }
    void add(int64_t val, size_t pos){
        operate(1, val, pos, pos+1);
    }
    void add(int64_t val, size_t left, size_t right){
        operate(1, val, left, right);
    }

    void dump(){
        for(int i=1;i<2*N;i++){
            eval(i);
            cerr << val[i] << " ";
        }
        cerr << endl;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    segment_tree st(n);

    for(int i=0;i<q;i++){
        int com;
        cin >> com;
        if(com == 0){
            int s, t, x;
            cin >> s >> t >> x;
            st.update(x, s, t+1);
        }else{
            int s, t;
            cin >> s >> t;
            cout << st.get_sum(s, t+1) << endl;
        }
        //st.dump();
    }
    
    return 0;
}