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;

/*Range Add Min(Max) Query*/
/*区間加算、区間Min,区間Max*/

class RSUQ{
public: 
  typedef long long ll;

  //マージ可能な主データ型
  struct D{
    ll value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(ll value):value(value){}
    bool operator < (D a)const {return value < a.value;}
  };

  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    ll value;
    T():type(0),value(0){}
    T(int type,ll value):type(type),value(value){}
  };

  
  int n, n_;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSUQ(){n=-1;}
  RSUQ(int n_):n_(n_){
    n=1;
    while(n < n_) n *= 2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  inline D merge(D a,D b){return a.value + b.value;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    ll type = td[k].type;
    ll v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    
    len /= 2;
    {
      int l = k*2+1;
      dat[l].value = v * len;
      td[l].type = type;
      td[l].value = v;
    }
    {
      int r = k*2+2;
      dat[r].value = v * len;
      td[r].type = type;
      td[r].value = v;
    }
  }

  D write(int k, D x, int len){
    dat[k].value = x.value * len;
    td[k].type = 1;
    td[k].value = x.value;
    return dat[k];
  }

  D test(int a,int b,D x, bool flag){
    
    function<D(int,int,int)> dfs = [&](int k, int l, int r){
      if(r <= a||b <= l) return flag? dat[k]:returnD;
      if(a <= l && r <= b) return flag? write(k, x, r - l):dat[k];
      delay(k, r - l);
      D vl = dfs(k*2+1, l, (l+r)/2);
      D vr = dfs(k*2+2, (l+r)/2, r);
      return flag? (dat[k] = merge(vl, vr)):merge(vl, vr);
    };
    return dfs(0, 0, n);
  }

  //[l,r)の値をx変更　query(l,r,x)
  void update(int l,int r,ll x){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    test(l, r, D(x), true);
  }
  
  //[l,r)の合計値を得る　find(a,b);
  ll find(int l,int r){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    D res = test(l, r, D(), false);
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RSUQ rsuq(n);

  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rsuq.update(s,t+1,x);
    }
    
    if(cmd == 1){
      int s,t;
      cin>>s>>t;
      cout<<rsuq.find(s,t+1)<<endl;
    }
  }
  
  return 0;
}