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>
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

size_t ceil_pow2(size_t n) {
  --n;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  n |= n >> 32;
  return n+1;
}

constexpr int INF = 1000000000;

class SegmentTree {
 public:
  SegmentTree(const size_t n)
    : size(ceil_pow2(n)), data(2*size, INF), sum(2*size) {}
  // [l, r)
  void query_update(const size_t l, const size_t r, const int x) {
    update_impl(1, 0, size, l, r, x);
  }
  int query_sum(const size_t l, const size_t r) const {
    return sum_impl(1, 0, size, l, r);
  }
 private:
  void update_impl(const size_t idx, const size_t rngl, const size_t rngr,
      const size_t l, const size_t r, const int x) {
    if (r <= rngl || rngr <= l) return;
    if (idx >= size) {
      data[idx] = x;
      sum[idx] = x;
      return;
    }
    const auto mid = (rngl + rngr) / 2;
    if (l <= rngl && rngr <= r) {
      data[idx] = x;
      sum[idx] = x * (rngr - rngl);
    } else {
      if (data[idx] != INF) {
        update_impl(2*idx,   rngl, mid,  rngl, rngr, data[idx]);
        update_impl(2*idx+1, mid,  rngr, rngl, rngr, data[idx]);
      }
      data[idx] = INF;
      update_impl(2*idx,   rngl, mid,  l, r, x);
      update_impl(2*idx+1, mid,  rngr, l, r, x);
      sum[idx] = sum[2*idx] + sum[2*idx+1];
    }
  }
  int sum_impl(const size_t idx, const size_t rngl, const size_t rngr,
      const size_t l, const size_t r) const {
    if (r <= rngl || rngr <= l) return 0;
    if (idx >= size) return sum[idx];
    const auto mid = (rngl + rngr) / 2;
    if (data[idx] != INF) {
      return data[idx] * (min(r, rngr) - max(l, rngl));
    }
    if (l <= rngl && rngr <= r) {
      return sum[idx];
    } else {
      return sum_impl(2*idx,   rngl, mid,  l, r)
        +    sum_impl(2*idx+1, mid,  rngr, l, r);
    }
  }
  const size_t size;
  vecint data;
  vecint sum;
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  SegmentTree st(n);
  st.query_update(0, n, 0);
  REP(i,q) {
    int a;
    cin>>a;
    if (a == 0) {
      int s,t,x;
      cin>>s>>t>>x;
      st.query_update(s, t+1, x);
    } else {
      int s,t;
      cin>>s>>t;
      cout<<st.query_sum(s, t+1)<<endl;
    }
  }
  return 0;
}