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;
struct Seg {
  long long sum[100100 << 2];
  int ma[100100 << 2], se[100100 << 2], cnt[100100 << 2];
  void up(int o) {
    sum[o] = sum[(o << 1)] + sum[((o << 1) | 1)];
    ma[o] = max(ma[(o << 1)], ma[((o << 1) | 1)]);
    cnt[o] = 0;
    if (ma[o] == ma[(o << 1)]) cnt[o] += cnt[(o << 1)];
    if (ma[o] == ma[((o << 1) | 1)]) cnt[o] += cnt[((o << 1) | 1)];
    se[o] = max(se[(o << 1)], se[((o << 1) | 1)]);
    if (ma[(o << 1)] != ma[((o << 1) | 1)])
      se[o] = max(se[o], min(ma[(o << 1)], ma[((o << 1) | 1)]));
  }
  void build(int o, int l, int r) {
    if (l == r) {
      ma[o] = 0x3f3f3f3f;
      sum[o] = 0x3f3f3f3f;
      se[o] = -1;
      cnt[o] = 1;
      return;
    }
    build((o << 1), l, ((l + r) >> 1));
    build(((o << 1) | 1), ((l + r) >> 1) + 1, r);
    up(o);
  }
  void deal(int o, int val) {
    if (val >= ma[o]) return;
    sum[o] -= 1LL * cnt[o] * (ma[o] - val);
    ma[o] = val;
  }
  void down(int o) {
    deal((o << 1), ma[o]);
    deal(((o << 1) | 1), ma[o]);
  }
  void update(int o, int l, int r, int y1, int y2, int val) {
    if (val >= ma[o]) return;
    if (y1 <= l && y2 >= r && val > se[o]) {
      deal(o, val);
      return;
    }
    down(o);
    if (y1 <= ((l + r) >> 1)) update((o << 1), l, ((l + r) >> 1), y1, y2, val);
    if (y2 > ((l + r) >> 1))
      update(((o << 1) | 1), ((l + r) >> 1) + 1, r, y1, y2, val);
    up(o);
  }
  long long query(int o, int l, int r, int y1, int y2) {
    if (y1 <= l && y2 >= r) return sum[o];
    long long ans = 0;
    down(o);
    if (y1 <= ((l + r) >> 1)) ans += query((o << 1), l, ((l + r) >> 1), y1, y2);
    if (y2 > ((l + r) >> 1))
      ans += query(((o << 1) | 1), ((l + r) >> 1) + 1, r, y1, y2);
    return ans;
  }
} tr[4][2];
set<int> hs[4];
int q, n = 100000, typ, l, r;
void solve(int u, int v, int w, int k) {
  while (true) {
    auto t = hs[u].lower_bound(l);
    if (t != hs[u].end() && *t <= r) {
      tr[u][0].update(1, 1, n, *t, *t, 0);
      tr[u][1].update(1, 1, n, *t, *t, 0);
      if (w != -1) {
        tr[w][0].update(1, 1, n, *t, *t, 0);
        tr[w][1].update(1, 1, n, *t, *t, 0);
      }
      hs[u].erase(t);
      hs[v].insert(*t);
    } else
      break;
  }
}
int main() {
  scanf("%d", &q);
  for (int i = 0; i < 4; ++i) {
    tr[i][0].build(1, 1, n);
    tr[i][1].build(1, 1, n);
  }
  for (int i = 1; i < n; ++i) hs[0].insert(i);
  while (q--) {
    scanf("%d%d%d", &typ, &l, &r);
    --r;
    if (typ == 1) {
      int k;
      scanf("%d", &k);
      if (k > 0) {
        for (int j = 0; j < 4; ++j) tr[j][0].update(1, 1, n, l, r, k);
        solve(0, 2, 1, k);
        solve(1, 3, -1, k);
      } else {
        for (int j = 0; j < 4; ++j) tr[j][1].update(1, 1, n, l, r, -k);
        solve(0, 1, 2, -k);
        solve(2, 3, -1, -k);
      }
    } else {
      long long ans = 0;
      for (int j = 0; j < 4; ++j) {
        if (j == 0 || j == 3)
          ans += tr[j][0].query(1, 1, n, l, r) + tr[j][1].query(1, 1, n, l, r);
        else
          ans -= tr[j][0].query(1, 1, n, l, r) + tr[j][1].query(1, 1, n, l, r);
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
