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>
#define int long long
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
template<typename DATA_TYPE, typename LAZY_TYPE, typename F, typename G, typename H>
class SegmentTree {
  private:
	size_t size;

	F f;
	G g;
	H h;

	std::vector<DATA_TYPE> data;
	std::vector<LAZY_TYPE> lazy;
	DATA_TYPE data_init;
	LAZY_TYPE lazy_init;

	SegmentTree() : size(0) {}

	void eval(int length, size_t index) {
		if (lazy[index] == lazy_init) return;
		if (index * 2 + 1 < size * 2 - 1) {
			lazy[index * 2 + 1] = h(lazy[index * 2 + 1], lazy[index]);
			lazy[index * 2 + 2] = h(lazy[index * 2 + 2], lazy[index]);
		}
		data[index] = g(data[index], lazy[index], length);
		lazy[index] = lazy_init;
	}

	DATA_TYPE update(size_t begin, size_t end, LAZY_TYPE update_value, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data[index];
		if (begin <= left && right <= end) {
			lazy[index] = h(lazy[index], update_value);
			return g(data[index], lazy[index], right - left);
		}
		return data[index] = f(update(begin, end, update_value, index * 2 + 1, left, (left + right) / 2), update(begin, end, update_value, index * 2 + 2, (left + right) / 2, right));
	}

	DATA_TYPE query(size_t begin, size_t end, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data_init;
		if (begin <= left && right <= end) return data[index];
		return f(query(begin, end, index * 2 + 1, left, (left + right) / 2), query(begin, end, index * 2 + 2, (left + right) / 2, right));
	}

  public:
	SegmentTree(size_t data_size, F f, G g, H h, DATA_TYPE data_init, LAZY_TYPE lazy_init) : f(f), g(g), h(h), data_init(data_init), lazy_init(lazy_init) {
		size = 1;
		while (size < data_size) size <<= 1U;
		data.resize(2 * size - 1, data_init);
		lazy.resize(2 * size - 1, lazy_init);
	}

	void build(std::vector<DATA_TYPE> input_data) {
		if (input_data.size() > size) {
			std::cerr << "segment tree::build : input oversize data\n";
			exit(-1);
		}
		for (int i = 0; i < input_data.size(); ++i) {
			data[i + size - 1] = input_data[i];
		}
		for (int i = size - 2; i >= 0; --i) {
			data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	void update(size_t begin, size_t end, LAZY_TYPE update_value) {
		update(begin, end, update_value, 0, 0, size);
	}

	DATA_TYPE query(size_t begin, size_t end) {
		return query(begin, end, 0, 0, size);
	}
};
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	auto f = [](int a, int b) { return a + b; };
    auto g = [](int a, int b, size_t len) { return b == INT_MIN ? a : b * len; };
	auto h = [](int a, int b) { return b == INT_MIN ? a : b; };
	int n, q;
	cin >> n >> q;
	SegmentTree<int, int, decltype(f), decltype(g), decltype(h)> segTree(n, f, g, h, 0, INT_MIN);
	rep(i, q) {
		int qt;
		cin >> qt;
		if (qt) {
			int s, t;
			cin >> s >> t;
			cout << segTree.query(s, t + 1) << endl;
		}
		else {
			int s, t, x;
			cin >> s >> t >> x;
			segTree.update(s, t + 1, x);
		}
	}
}

