Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:

* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $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 $add(s, t, x)$ and '1' denotes $find(s, t)$.

Output

For each $find$ query, print the minimum value.

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

-2
0
1
-1
#include <bits/stdc++.h>
using namespace std;

#define rep(name, times) for (int name = 0, until##name = (times); name < until##name; name++)
#define repr(name, times) for (int name = (times)-1; name >= 0; name--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;

struct segtree {
  int n, h; vector<int> data, d;
  segtree(int n): n(n), h(32 - __builtin_clz(n)), data(n<<1), d(n) { }
  void apply(int p, int x) {
    data[p] += x;
    if (p < n) d[p] += x;
  }
  void build(int p) {
    for (; p > 1; p >>= 1) data[p>>1] = min(data[p], data[p^1]) + d[p>>1];
  }
  void push(int p) {
    repr(i, h) {
      int q = p >> (i+1);
      if (not d[q]) continue;
      apply(q<<1, d[q]);
      apply(q<<1|1, d[q]);
      d[q] = 0;
    }
  }
  void update(int l, int r, int x) {
    int l0 = l, r0 = r;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l&1) apply(l++, x);
      if (r&1) apply(--r, x);
    }
    build(l0+n); build(r0+n-1);
  }
  int query(int l, int r) {
    l += n; r += n;
    push(l); push(r-1);
    int res = numeric_limits<int>::max();
    for (; l < r; l >>= 1, r >>= 1) {
      if (l&1) res = min(res, data[l++]);
      if (r&1) res = min(res, data[--r]);
    }
    return res;
  }
};

int main() {
  int n,q; scanf("%d%d", &n,&q);
  int c,s,t,x;
  segtree st(n);
  rep(i, q) {
//    cerr << i << endl;
//    rep(i, n+n-1) cerr << st.data[i+1] << " ";
//    cerr << endl;
    scanf("%d", &c);
//    rep(i, n-1) cerr << st.d[i+1] << " ";
//    cerr << endl;
    if (c) {
//      cerr << "#0" << endl;
      scanf("%d%d",&s,&t);
      printf("%d\n", st.query(s,t+1));
    } else {
//      cerr << "#1" << endl;
      scanf("%d%d%d",&s,&t,&x);
//      cerr << s << " " << t << " " << x << endl;
      st.update(s, t+1, x);
    }
  }
}

