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;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
struct segtree{
private:
	T init;
	int n;
	function<T(T,T)> op;
	vector<T>arr;
	vector<T>st;
	vector<T>lz;
	void build(int lo,int hi,int u){
		if(lo==hi){
			st[u]=arr[lo];
		}
		else{
			int mi=(hi+lo)>>1;
			build(lo,mi,u<<1);
			build(mi+1,hi,u<<1|1);
			st[u]=op(st[u<<1],st[u<<1|1]);
		}
	}
	void apply(T x,int u,int lo,int hi){
// 		st[u]+=x*(hi-lo+1);
// 		st[u]+=x;
//		st[u]=x;
 		st[u]=x*(hi-lo+1);
// 		lz[u]+=x;
		lz[u]=x;
	}
	void push(int u,int lo,int hi){
		if(lz[u]!=init){
			int mi=(lo+hi)>>1;
			apply(lz[u],u<<1,lo,mi);
			apply(lz[u],u<<1|1,mi+1,hi);
			lz[u]=init;
		}
	}
	void modify(int l,int r,T x,int u,int lo,int hi){
		if(r<lo||l>hi||l>r)return;
		if(l<=lo&&r>=hi){
			apply(x,u,lo,hi);
			return;
		}
		push(u,lo,hi);
		int mi=(lo+hi)>>1;
		if(mi>=r){
			modify(l,r,x,u<<1,lo,mi);
		}
		else if(mi<l){
			modify(l,r,x,u<<1|1,mi+1,hi);
		}
		else{
			modify(l,mi,x,u<<1,lo,mi);
			modify(mi+1,r,x,u<<1|1,mi+1,hi);
		}
		st[u]=op(st[u<<1],st[u<<1|1]);
	}
	T query(int l,int r,int u,int lo,int hi){
		if(l>r||l>hi||r<lo)return init;
		if(l<=lo&&r>=hi){
			return st[u];
		}
		push(u,lo,hi);
		int mi=(hi+lo)>>1;
		if(mi>=r){
			return query(l,r,u<<1,lo,mi);
		}
		else if(mi<l){
			return query(l,r,u<<1|1,mi+1,hi);
		}
		else{
			return op(query(l,mi,u<<1,lo,mi),query(mi+1,r,u<<1|1,mi+1,hi));
		}
	}
public:
	segtree(T n,function<T(T,T)> op):n(n),st(n*4),op(op),lz(n*4){
		init=T();
	}
	segtree(vector<T> v,function<T(T,T)> op):n(v.size()),st(v.size()*4),op(op),lz(v.size()*4){
		init=T();
		arr=v;
		build(0,n-1,1);
	}
	T query(int l,int r){
		return query(l,r,1,0,n-1);
	}
	void setinit(T x){
		init=x;
		for(int i=0;i<4*n;i++){
//			st[i]=init;
			lz[i]=init;
		}
	}
	void modify(int l,int r,T x){
		modify(l,r,x,1,0,n-1);
	}
	void debug(){
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				cout<<i<<" "<<j<<" "<<query(i,j)<<"\n";
			}
		}
	}
};
int main(){
	int n,q;
	cin>>n>>q;
	segtree<int> seg(n,[](int a,int b){
		return a+b;
	});
	seg.setinit(INF);
	while(q--){
		int c;
		cin>>c;
		if(c){
			int l,r;
			cin>>l>>r;
			if(l==-1)seg.debug();
			else cout<<seg.query(l,r)<<"\n";
		}
		else{
			int l,r,x;
			cin>>l>>r>>x;
			seg.modify(l,r,x);
			
		}
	}
}