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;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template <class M, class OM = M>
struct DelaySegmentTree{
  using FX = function<M(M, M)>;
  using FA = function<M(M, OM)>;
  using FM = function<OM(OM, OM)>;
  using FP = function<M(M, int)>;
  FX fx;
  FA fa;
  FM fm;
  FP fp;
  int n;
  M ex;
  OM em;
  vector<M> data;
  vector<OM> delay;

  DelaySegmentTree(int sz, FX fx, FA fa, FM fm, FP fp, M ex, OM em) 
  : fx(fx), fa(fa), fm(fm), fp(fp), ex(ex), em(em), data(sz*4, ex), delay(sz*4, em){
    n = 1; while(n < sz) n *= 2;
  }

  void build(vector<M> v){
    for(int k = 0; k < v.size(); k++){
      data[k+n-1] = v[k];
    }
    for(int k = n-2; k >= 0; k--){
      data[k] = fx(data[2*k+1], data[2*k+2]);
    }
  }

  void eval(int k, int len){
    if(delay[k] == em) return;
    if(k < n-1){
      delay[2*k+1] = fm(delay[2*k+1], delay[k]);
      delay[2*k+2] = fm(delay[2*k+2], delay[k]);
    }
    data[k] = fa(data[k], fp(delay[k], len));
    delay[k] = em;
  }

  void update(int a, int b, OM x){ update(a, b, x, 0, 0, n); }
  void update(int a, int b, OM x, int k, int l, int r){
    eval(k, r - l);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay[k] = fm(delay[k], x);
      eval(k, r - l);
    }else{
      update(a, b, x, 2*k+1, l, (l+r)/2);
      update(a, b, x, 2*k+2, (l+r)/2, r);
      data[k] = fx(data[2*k+1], data[2*k+2]);
    }
  }

  M getval(int a, int b){ return getval(a, b, 0, 0, n); }
  M getval(int a, int b, int k, int l, int r){
    eval(k, r - l);
    if(b <= l || r <= a) return ex;
    if(a <= l && r <= b) return data[k];
    M vl = getval(a, b, 2*k+1, l, (l+r)/2);
    M vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return fx(vl, vr);
  }

  void print(int n){
    cout << "[";
    for(int i = 0; i < n; i++){
      cout << getval(i, i+1) << ", ";
    }
    cout << "]" << endl;
  }
};


signed main(){

  int n, q; cin >> n >> q;
  auto fx = [](int a, int b){ return min(a, b); };
  auto fa = [](int a, int b){ return a + b; };
  auto fm = [](int a, int b){ return a + b; };
  auto fp = [](int a, int b){ return a; };
  DelaySegmentTree<int> seg(n, fx, fa, fm, fp, INF, 0);
  seg.build(vector<int>(n, 0));

  for(int i = 0; i < q; i++){
    int qt; cin >> qt;
    if(qt == 0){
      int s, t, x; cin >> s >> t >> x;
      seg.update(s, t+1, x);
    }else{
      int s, t; cin >> s >> t;
      cout << seg.getval(s, t+1) << endl;
    }
    //seg.print(n);
  }

  return 0;
}