Problem: 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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int infty = (int)((1LL << 31) - 1);
struct segment_tree {
  public:
    int n, N;
    vector<int> tr, lz;
    segment_tree (vector<int> v) {
      n = v.size();
      N = 1;
      while (N < n) N <<= 1;
      tr.resize(2 * N);
      lz.resize(2 * N, 0);
      for (int i = 0; i < n; i++) tr[N + i] = v[i];
      for (int i = N - 1; i >= 1; i--) tr[i] = min(tr[2 * i], tr[2 * i + 1]);
    }
    inline void pg (int k, int L, int R) {
      if (lz[k]) {
        if (k < N) {
          lz[2 * k] += lz[k];
          lz[2 * k + 1] += lz[k];
        }
        tr[k] += lz[k];
        lz[k] = 0;
      }
    }
    void add (int l, int r, int x, int k = 1, int L = 0, int R = -1) {
      if (R == -1) R = N;
      pg(k, L, R);
      if (r <= L || R <= l) {
        return;
      } else if (l <= L && R <= r) {
        lz[k] += x;
        pg(k, L, R);
      } else {
        int C = (L + R) / 2;
        add(l, r, x, 2 * k, L, C);
        add(l, r, x, 2 * k + 1, C, R);
        tr[k] = min(tr[2 * k], tr[2 * k + 1]);
      }
    }
    int getMin (int l, int r, int k = 1, int L = 0, int R = -1) {
      if (R == -1) R = N;
      pg(k, L, R);
      if (r <= L || R <= l) {
        return infty;
      } else if (l <= L && R <= r) {
        return tr[k];
      } else {
        int C = (L + R) / 2;
        return min(getMin(l, r, 2 * k, L, C), getMin(l, r, 2 * k + 1, C, R));
      }
    }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  segment_tree sgt(vector<int>(n, 0));
  while (q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      sgt.add(s, ++t, x);
    } else {
      int s, t;
      cin >> s >> t;
      int ret = sgt.getMin(s, ++t);
      cout << ret << '\n';
    }
  }
  return 0;
}