Nagini, being a horcrux You-know-who created with the murder of Bertha Jorkins, has accumulated its army of snakes and is launching an attack on Hogwarts school. 

Hogwarts' entrance can be imagined as a straight line (x-axis) from 1 to 105. Nagini is launching various snakes at the Hogwarts entrance. Each snake lands parallel to the entrance, covering a segment at a distance k from x = l to x = r. Formally, each snake can be imagined as being a line segment between points (l, k) and (r, k). Note that k can be both positive and negative, but not 0.

Let, at some x-coordinate x = i, there be snakes at point (i, y1) and point (i, y2), such that y1 > 0 and y2 < 0. Then, if for any point (i, y3) containing a snake such that y3 > 0, y1 ≤ y3 holds and for any point (i, y4) containing a snake such that y4 < 0, |y2| ≤ |y4| holds, then the danger value at coordinate x = i is y1 + |y2|. If no such y1 and y2 exist, danger value is 0. 

Harry wants to calculate the danger value of various segments of the Hogwarts entrance. Danger value for a segment [l, r) of the entrance can be calculated by taking the sum of danger values for each integer x-coordinate present in the segment.

Formally, you have to implement two types of queries:

  * 1 l r k: a snake is added parallel to entrance from x = l to x = r at y-coordinate y = k (l inclusive, r exclusive). 
  * 2 l r: you have to calculate the danger value of segment l to r (l inclusive, r exclusive). 

Input

First line of input contains a single integer q (1 ≤ q ≤ 5·104) denoting the number of queries.

Next q lines each describe a query. Each query description first contains the query type typei (1 ≤ typei ≤ 2). This is followed by further description of the query. In case of the type being 1, it is followed by integers li, ri and ki (<image>,  - 109 ≤ ki ≤ 109, k ≠ 0). Otherwise, it just contains two integers, li and ri (1 ≤ li < ri ≤ 105).

Output

Output the answer for each query of type 2 in a separate line.

Examples

Input

3
1 1 10 10
1 2 4 -7
2 1 10


Output

34


Input

7
1 2 3 5
1 1 10 10
1 4 5 -5
2 4 8
1 1 10 -10
2 4 8
2 1 10


Output

15
75
170

Note

In the first sample case, the danger value for x-coordinates 1 is 0 as there is no y2 satisfying the above condition for x = 1.

Danger values for x-coordinates 2 and 3 is 10 + | - 7| = 17.

Danger values for x-coordinates 4 to 9 is again 0 as there is no y2 satisfying the above condition for these coordinates.

Thus, total danger value is 17 + 17 = 34.
#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 100010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 29;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
const int BLOCK = 300;
const int CNT = MAX_N / BLOCK + 10;
int Q;
int A[2][MAX_N];
int B[2][CNT];
bool zeros[2][CNT];
vector<int> C[2][CNT];
int sz[2][CNT];
long long sum[CNT];
inline void update(int& a, int b) {
  if (a == 0 || b == 0)
    a = a + b;
  else
    a = min(a, b);
}
void push(int id) {
  for (int p = 0; p < 2; p++) {
    if (!B[p][id]) continue;
    for (int i = id * BLOCK; i < (id + 1) * BLOCK; i++) {
      update(A[p][i], B[p][id]);
    }
    B[p][id] = 0;
  }
}
void pull(int id) {
  for (int p = int(0); p < int(2); p++) {
    bool ok = false;
    for (int i = id * BLOCK; i < (id + 1) * BLOCK; i++) {
      if (A[p][i] == 0) {
        ok = true;
        break;
      }
    }
    zeros[p][id] = ok;
    if (ok) continue;
    C[p][id].clear();
    for (int i = id * BLOCK; i < (id + 1) * BLOCK; i++) {
      if (A[1 - p][i] != 0) C[p][id].push_back(A[p][i]);
    }
    sz[p][id] = (int)(C[p][id]).size();
    sort((C[p][id]).begin(), (C[p][id]).end());
  }
  sum[id] = 0;
  for (int i = id * BLOCK; i < (id + 1) * BLOCK; i++) {
    if (A[0][i] && A[1][i]) {
      sum[id] += A[0][i] + A[1][i];
    }
  }
}
void update_block(int id, int p, int k) {
  int old = B[p][id];
  update(B[p][id], k);
  if (zeros[p][id]) {
    push(id);
    pull(id);
  } else {
    int extra = sz[p][id] - (int)(C[p][id]).size();
    if (old > k) {
      sum[id] -= extra * 1LL * (old - k);
    }
    while (!C[p][id].empty() && C[p][id].back() > k) {
      sum[id] -= C[p][id].back() - k;
      C[p][id].pop_back();
    }
  }
}
long long get_block(int id) { return sum[id]; }
void solve() {
  for (int p = int(0); p < int(2); p++)
    for (int k = int(0); k < int(CNT); k++) zeros[p][k] = true;
  cin >> Q;
  while (Q--) {
    int t, l, r, k, p;
    cin >> t >> l >> r;
    l--;
    r--;
    int lid = l / BLOCK, rid = r / BLOCK;
    if (t == 1) {
      cin >> k;
      p = (k >= 0);
      k = abs(k);
      push(lid);
      push(rid);
      while (l < r && l < (lid + 1) * BLOCK) {
        update(A[p][l], k);
        l++;
      }
      while (l < r && r > rid * BLOCK) {
        update(A[p][r - 1], k);
        r--;
      }
      pull(lid);
      pull(rid);
      for (int id = lid + 1; id < rid; id++) {
        update_block(id, p, k);
      }
    } else {
      long long ans = 0;
      push(lid);
      push(rid);
      while (l < r && l < (lid + 1) * BLOCK) {
        if (A[0][l] && A[1][l]) ans += A[0][l] + A[1][l];
        l++;
      }
      while (l < r && r > rid * BLOCK) {
        if (A[0][r - 1] && A[1][r - 1]) ans += A[0][r - 1] + A[1][r - 1];
        r--;
      }
      for (int id = lid + 1; id < rid; id++) {
        ans += get_block(id);
      }
      cout << ans << "\n";
      pull(lid);
      pull(rid);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  solve();
  return 0;
}
