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;
using ll = long long;

template<typename T, typename E> struct LazySegmentTree {
  using F = function<T(T, T)>;
  using G = function<T(T, E)>;
  using H = function<E(E, E)>;
  using P = function<E(E, int)>;

  int n;
  T ti;
  E ei;
  F f;
  G g;
  H h;
  P p;
  vector<T> data;
  vector<E> lazy;

  LazySegmentTree(int n_, F f, G g, H h, T ti = INT_MAX, E ei = INT_MAX,
                  vector<T> v = vector<T>(), P p = [](E a, int b) { return a; })
      : f(f), g(g), h(h), ti(ti), ei(ei), p(p) {
    init(n_);
    if (n_ == (int)v.size()) build(v);
  }
  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    data.assign(n * 2 - 1, ti);
    lazy.assign(n * 2 - 1, ei);
  }
  void build(vector<T> v) {
    for (int i = 0; i < v.size(); ++i) data[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  inline void eval(int len, int k) {
    if (lazy[k] == ei) return;
    if (k * 2 + 1 < n * 2 - 1) {
      lazy[k * 2 + 1] = h(lazy[k * 2 + 1], lazy[k]);
      lazy[k * 2 + 2] = h(lazy[k * 2 + 2], lazy[k]);
    }
    data[k] = g(data[k], p(lazy[k], len));
    lazy[k] = ei;
  }
  T update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return data[k];
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      return g(data[k], p(lazy[k], r - l));
    }
    T vl = update(a, b, x, k * 2 + 1, l, (l + r) / 2);
    T vr = update(a, b, x, k * 2 + 2, (l + r) / 2, r);
    return data[k] = f(vl, vr);
  }
  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return ti;
    if (a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

const ll INF = 1e12;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  LazySegmentTree<ll, ll>::F f = plus<ll>();
  LazySegmentTree<ll, ll>::G g = [](ll a, ll b) { return (b == INF) ? a : b; };
  LazySegmentTree<ll, ll>::H h = [](ll a, ll b) { return (b == INF) ? a : b; };
  LazySegmentTree<ll, ll>::P p = [](ll a, int b) { return (a == INF) ? a : a * b; };

  int n, q; cin >> n >> q;
  LazySegmentTree<ll, ll> seg(n, f, g, h, 0, INF, vector<ll>(), p);

  while (q--) {
    int com; cin >> com;
    if (com) {
      int s, t; cin >> s >> t;
      cout << seg.query(s, t + 1) << endl;
    } else {
      int s, t, x; cin >> s >> t >> x;
      seg.update(s, t + 1, x);
    }
  }
  return 0;
}