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;
using ll = long long;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

template<class T, class E>
struct SegTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> lazy;
  SegTree(int n_, F f, G g, H h, T d1, E d0, P p=[](E a, int b){ return a; })
    : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, d0);
  }
  void eval(int k, int l, int r) {
    if (lazy[k] == d0) return;
    dat[k] = g(dat[k], p(lazy[k], r - l));
    if (k < n - 1) {
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
    }
    lazy[k] = d0;
  }
  void update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    // cerr << "update: a = " << a << ", b = " << b << ", x = " << x << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  // return op[a..b)
  // k: node id, [l, r): node interval
  E query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    // cerr << "query: a = " << a << ", b = " << b << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    E vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    E vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
  void print() {
   int j = 2;
   for (int i = 0; i < 2 * n - 1; i++) {
     cerr << "(" << dat[i] << ", " << lazy[i] << ")";
     if (i == j - 2) { cerr << endl; j *= 2;}
     else { cerr << " "; }
   }
 }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  int n, q;
  cin >> n >> q;
  SegTree<ll, ll> seg(
    n,
    [](ll a, ll b){ return min(a, b); },
    [](ll a, ll b){ return a + b; },
    [](ll a, ll b){ return a + b; },
    INT_MAX,
    0
  );

  // seg.print();

  rep(i, q) {
    int t;
    cin >> t;
    if (t == 0) {
      int a, b;
      ll v;
      cin >> a >> b >> v;
      seg.update(a, b + 1, v);
    }
    else {
      int a, b;
      cin >> a >> b;
      cout << seg.query(a, b + 1) << endl;
    }

    // cerr << "i = " << i << endl;
    // seg.print();
  }

  return 0;
}

