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:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
int const TREE_SIZE = 1 << 20;
long long int seg_tree[TREE_SIZE] = {};
bool is_a[TREE_SIZE] = {}; // その区間に値が代入されたかどうか

long long int getsum(int a, int b, int index, int l, int r){
	
	// [a, b) の合計値を求める
	if(r <= a || b <= l){
		return 0;
	}
	if(a <= l && r <= b){
		return seg_tree[index];
	}
	if(is_a[index]){
		return seg_tree[index] / (r - l) * (min(r, b) - max(l, a)); // 
	}
	long long int ret = 0;
	ret += getsum(a, b, index * 2, l, (l + r) / 2);
	ret += getsum(a, b, index * 2 + 1, (l + r) / 2, r);
	return ret;
}

long long int update(int a, int b, int index, int num, int l, int r){
	
	// [a, b) を num に変更する
	
	if(r <= a || b <= l){
		//cout << l << " " << r << " " << seg_tree[index] << endl;
		return seg_tree[index];
	}
	if(a <= l && r <= b){
		seg_tree[index] = num * (r - l);
		is_a[index] = true;
		//cout << l << " " << r << " " << seg_tree[index] << endl;
		return seg_tree[index];
	}
	long long int ret = 0;
	if(is_a[index]){
		is_a[index * 2] = true;
		seg_tree[index * 2] = seg_tree[index] / 2;
		is_a[index * 2 + 1] = true;
		seg_tree[index * 2 + 1] = seg_tree[index] / 2;
		is_a[index] = false;
	}
	ret += update(a, b, index * 2, num, l, (l + r) / 2);
	ret += update(a, b, index * 2 + 1, num, (l + r) / 2, r);
	//cout << l << " " << r << " " << ret << endl;
	return seg_tree[index] = ret;
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 0; i < q; i++){
		long long int num, a, b, c;
		cin >> num;
		if(num == 0){
			cin >> a >> b >> c;
			update(a, b + 1, 1, c, 0, TREE_SIZE / 2);
		}else{
			cin >> a >> b;
			cout << getsum(a, b + 1, 1, 0, TREE_SIZE / 2) << endl;
		}
	}
	
	return 0;
}