#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

template< typename Monoid, typename OperatorMonoid = Monoid >
struct LazySegmentTree {
   using F = function< Monoid(Monoid, Monoid) >;
   using G = function< Monoid(Monoid, OperatorMonoid, int) >;
   using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;
   int sz;
   vector< Monoid > data;
   vector< OperatorMonoid > lazy;
   const F f;
   const G g;
   const H h;
   const Monoid M1;
   const OperatorMonoid OM0;
   LazySegmentTree(int n, const F f, const G g, const H h,
                   const Monoid &M1, const OperatorMonoid OM0)
         : f(f), g(g), h(h), M1(M1), OM0(OM0) {
      sz = 1;
      while(sz < n) sz <<= 1;
      data.assign(2 * sz, M1);
      lazy.assign(2 * sz, OM0);
   }

   void set(int k, const Monoid &x) {
      data[k + sz] = x;
   }
   void build() {
      for(int k = sz - 1; k > 0; k--) {
         data[k] = f(data[2 * k + 0], data[2 * k + 1]);
      }
   }
   void propagate(int k, int len) {
      if(lazy[k] != OM0) {
         if(k < sz) {
            lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
            lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
         }
         data[k] = g(data[k], lazy[k], len);
         lazy[k] = OM0;
      }
   }
   Monoid update(int a, int b, const OperatorMonoid &x, int k, int l, int r) {
      propagate(k, r - l);
      if(r <= a || b <= l) {
         return data[k];
      } else if(a <= l && r <= b) {
         lazy[k] = h(lazy[k], x);
         propagate(k, r - l);
         return data[k];
      } else {
         return data[k] = f(update(a, b, x, 2 * k + 0, l, (l + r) >> 1),
                            update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
      }
   }
   Monoid update(int a, int b, const OperatorMonoid &x) {
      return update(a, b, x, 1, 0, sz);
   }
   Monoid query(int a, int b, int k, int l, int r) {
      propagate(k, r - l);
      if(r <= a || b <= l) {
         return M1;
      } else if(a <= l && r <= b) {
         return data[k];
      } else {
         return f(query(a, b, 2 * k + 0, l, (l + r) >> 1),
                  query(a, b, 2 * k + 1, (l + r) >> 1, r));
      }
   }
   Monoid query(int a, int b) {
      return query(a, b, 1, 0, sz);
   }
   Monoid operator[](const int &k) {
      return query(k, k + 1);
   }
};

signed main()
{
   int n, q; cin >> n >> q;
   V<int> c(q), s(q), t(q), x(q);
   REP(i, q) {
      cin >> c[i];
      if (c[i] == 0) {
         cin >> s[i] >> t[i] >> x[i];
      } else {
         cin >> s[i] >> t[i];
      }
   }
   LazySegmentTree<int> lsegt(n,
         [](int a,int b){ return a + b; },
         [](int a,int b,int c){ return b * c; },
         [](int a,int b){ return b; }, 0, INF);
   REP(i, q) {
      if (c[i] == 0) {
         lsegt.update(s[i], t[i]+1, x[i]);
      } else {
         cout << lsegt.query(s[i], t[i]+1) << endl;
      }
   }

   return 0;
}


Measured memory_bytes: 9884