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>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
std::mt19937 rnd(time(NULL));
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
struct data {
  long long sum;
  int mx[2], second[2], sm[2];
  char f;
} seg[270000];
data operator+(const data& a, const data& b) {
  data c;
  c.sum = a.sum + b.sum;
  for (int i = 0; i < 2; ++i) {
    c.mx[i] = std::max(a.mx[i], b.mx[i]);
    c.second[i] = std::max(a.mx[i] == c.mx[i] ? a.second[i] : a.mx[i],
                           b.mx[i] == c.mx[i] ? b.second[i] : b.mx[i]);
    c.sm[i] = (a.mx[i] == c.mx[i]) * a.sm[i] + (b.mx[i] == c.mx[i]) * b.sm[i];
  }
  c.f = a.f & b.f;
  return c;
}
int tag[270000][2];
void upd(int x, int d, int o) {
  seg[x].mx[o] += d, seg[x].sum += 1ll * d * seg[x].sm[o], tag[x][o] += d;
}
void down(int x) {
  for (int i = 0; i < 2; ++i)
    if (tag[x][i]) {
      if (seg[x << 1].mx[i] == seg[x].mx[i] - tag[x][i])
        upd(x << 1, tag[x][i], i);
      if (seg[x << 1 | 1].mx[i] == seg[x].mx[i] - tag[x][i])
        upd(x << 1 | 1, tag[x][i], i);
      tag[x][i] = 0;
    }
}
void update(int x, int l, int r, int L, int R, int d, int o) {
  if (L <= l && r <= R && (seg[x].f & 1 << o)) {
    if (seg[x].mx[o] <= d) return;
    if (seg[x].second[o] < d) return upd(x, d - seg[x].mx[o], o);
  }
  if (l == r) {
    seg[x].f |= 1 << o, seg[x].mx[o] = d;
    if (seg[x].f == 3)
      seg[x].sum = seg[x].mx[0] + seg[x].mx[1], seg[x].sm[0] = seg[x].sm[1] = 1;
    return;
  }
  down(x);
  if (L <= ((l + r) >> 1)) update(x << 1, l, ((l + r) >> 1), L, R, d, o);
  if (((l + r) >> 1) < R) update(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R, d, o);
  seg[x] = seg[x << 1] + seg[x << 1 | 1];
}
void build(int x, int l, int r) {
  seg[x].second[0] = seg[x].second[1] = -1;
  if (l == r) return;
  build(x << 1, l, ((l + r) >> 1)), build(x << 1 | 1, ((l + r) >> 1) + 1, r);
}
long long query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return seg[x].sum;
  down(x);
  if (L <= ((l + r) >> 1))
    if (((l + r) >> 1) < R)
      return query(x << 1, l, ((l + r) >> 1), L, R) +
             query(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R);
    else
      return query(x << 1, l, ((l + r) >> 1), L, R);
  else
    return query(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R);
}
int main() {
  int m = gi(), n = 100000;
  build(1, 1, n);
  int o, l, r, d;
  while (m--) {
    o = gi(), l = gi(), r = gi() - 1;
    if (o == 1)
      if ((d = gi()) < 0)
        update(1, 1, n, l, r, -d, 0);
      else
        update(1, 1, n, l, r, d, 1);
    else
      printf("%lld\n", query(1, 1, n, l, r));
  }
  return 0;
}
