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>
#define int long long
using namespace std;

/*Range Add Min(Max) Query*/
/*区間加算、区間Min,区間Max*/

template<typename D, int toMaxQuery = 0, int useAssert = 1>
class RMAQ{
public :
  struct T{ //遅延データ
    int type; //0 - empty, 1 - add
    D value;
    T():type(0){}
    T(int type, D value):type(type), value(value){}
  };
  int n, n_;
  D initValue;        //範囲外の時に返す値。
  vector<D> dat;
  vector<T> td;
  RMAQ(){n=-1;}
  RMAQ(int n_, D initValue):n_(n_), initValue(initValue){
    n=1;
    while(n<n_)n*=2;
    td.resize(2*n-1, T());
    dat.resize(2*n-1, 0);
  }

  //目的データのマージ
  inline D mergeD(D l, D r){return toMaxQuery? max(l, r):min(l, r);}

  //遅延データのマージ
  inline T mergeT(const T &from,const T &to){
    if(from.type == 0) return to;
    if(to.type == 0) return from;
    return T(1, from.value + to.value);
  }

  //目的データに遅延データを反映
  inline void apply(D &a, const T &b){
    if(b.type == 0) return;
    a += b.value;
  }

  D dfs(int a, int b,const T x, int k, int l, int r){
    if(r <= a || b <= l) return x.type == 0? initValue:dat[k];
    if(a <= l && r <= b){
      td[k] = mergeT(td[k], x);
      apply(dat[k], x);
      return dat[k];
    }
    int kl = k * 2 + 1, kr = k * 2 + 2;
    { //遅延を子に反映
      td[kl] = mergeT(td[kl], td[k]);
      td[kr] = mergeT(td[kr], td[k]);
      apply(dat[kl], td[k]);
      apply(dat[kr], td[k]);
      td[k] = T();
    }
    D vl = dfs(a, b, x, kl, l, (l+r)/2);
    D vr = dfs(a, b, x, kr, (l+r)/2, r);
    return x.type == 0? mergeD(vl,vr) : (dat[k] = mergeD(vl, vr));
  }

  //[l,r)の値にx加算　add(l,r,x)
  void add(int l,int r, D x){
    if(useAssert) assert(l <= r), assert(l <= n && r <= n), assert(l >= 0 && r >= 0);
    dfs(l, r,  T(1, x), 0, 0, n);
  }

  //[l,r)の最小値を得る　get(l,r);
  D get(int l,int r){
    if(useAssert) assert(l <= r), assert(l <= n && r <= n), assert(l >= 0 && r >= 0);
    return dfs(l, r, T(0, initValue), 0 , 0 ,n);
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  RMAQ <long long> rmaq(n, 1LL<<50);
  while(q--){
    int ord;
    cin>>ord;
    if(ord == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rmaq.add(s,t+1,x);
    }
    if(ord == 1){
      int s,t;
      cin>>s>>t;
      cout<<rmaq.get(s,t+1)<<endl;
    }
  }

  return 0;
}