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<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<typename X,typename M>
  struct segtree{
    using FX=function<X(X,X)>;
    using FA=function<X(X,M)>;
    using FM=function<M(M,M)>;
    int n;
    FX fx;
    FA fa;
    FM fm;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    segtree(int n_,FX fx_,FA fa_,FM fm_,X ex_,M em_)
      :n(),fx(fx_),fa(fa_),fm(fm_),ex(ex_),em(em_),dat(n_*4,ex),lazy(n_*4,em){
        int x=1;
        while(n_>x){
          x*=2;
        }
        n=x;
      }
    void set(int i,X x){
      dat[i+n-1]=x;
    }
    void build(){
      for(int k=n-2;k>=0;k--){
        dat[k]=fx(dat[2*k+1],dat[2*k+2]);
      }
    }
    void eval(int k){
      if(lazy[k]==em){
        return;
      }
      if(k<n-1){
        lazy[k*2+1]=fm(lazy[k*2+1],lazy[k]);
        lazy[k*2+2]=fm(lazy[k*2+2],lazy[k]);
      }
      dat[k]=fa(dat[k],lazy[k]);
      lazy[k]=em;
    }
    void update(int a,int b,M x,int k,int l,int r){
      eval(k);
      if(a<=l && r<=b){
        lazy[k]=fm(lazy[k],x);
        eval(k);
      }
      else if(a<r && l<b){
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=fx(dat[k*2+1],dat[k*2+2]);
      }
    }
    void update(int a,int b,M x){
      update(a,b,x,0,0,n);
    }
    X query_sub(int a,int b,int k,int l,int r){
      eval(k);
      if(r<=a  || b<=l){
        return ex;
      }
      else if(a<=l && r<=b){
        return dat[k];
      }
      else{
        X vl=query_sub(a,b,k*2+1,l,(l+r)/2);
        X vr=query_sub(a,b,k*2+2,(l+r)/2,r);
        return fx(vl,vr);
      }
    }
    X query(int a,int b){
      return query_sub(a,b,0,0,n);
    }
  };
int main(){
  using X=int;
  using M=int;
  auto fx=[](X x1,X x2) -> X{return min(x1,x2);};
  auto fa=[](X x,M m) -> X{return x+m;};
  auto fm=[](M m1,M m2) -> M{return m1+m2;};
  int ex=numeric_limits<int>::max();
  int em=0;
  segtree<X,M> seg(100010,fx,fa,fm,ex,em);
  int i,n,q,a,b,c,d;
  cin >> n >> q;
  for(i=0;i<n;i++){
    seg.set(i,0);
  }
  seg.build();
  for(i=0;i<q;i++){
    cin >> a;
    if(a==0){
      cin >> b >> c >> d;
      seg.update(b,c+1,d);
    }
    else{
      cin >> b >> c;
      cout << seg.query(b,c+1) << endl;
    }
  }
  return 0;
}