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<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmax(a,b) a=max(a,b);
#define chmin(a,b) a=min(a,b);
class Segtree{
	
	private:
	int V;
	typedef struct st{
		ll a;
	}st;
	st st0=(st){(ll)1e18};
	typedef struct op{
		ll a;
	}op;
	op op0=(op){0};
	st f(st p,st q){
		return (st){min(p.a,q.a)};
	}
	void g(st &p,op q){
		p.a+=q.a;
	}
	void h(op &p,op q){
		p.a+=q.a;
	}
	
	st *dat;
	op *laz;
	
	st propagate(ll k){
		if(k<V){
			h(laz[k*2],laz[k]);
			h(laz[k*2+1],laz[k]);
		}
		g(dat[k],laz[k]);
		laz[k]=op0;
		return dat[k];
	}
	void upd(ll l,ll r,op p){
		l+=V,r+=V+1;
		for(ll d=20;d>=0;d--){
			propagate(l>>d);
			propagate(r>>d);
		}
		for(ll a=l,b=r;a<b;a>>=1,b>>=1){
			if(a&1){h(laz[a],p);a++;}
			if(b&1){b--;h(laz[b],p);}
		}
		for(ll a=l,b=r;a+b;a>>=1,b>>=1){
			dat[a/2]=f(propagate(a/2*2),propagate(a/2*2+1));
			dat[b/2]=f(propagate(b/2*2),propagate(b/2*2+1));
		}
	}
	st qry(ll l,ll r){
		l+=V,r+=V+1;
		for(ll d=20;d>=0;d--){
			propagate(l>>d);
			propagate(r>>d);
		}
		st L=st0,R=st0;
		for(ll a=l,b=r;a<b;a>>=1,b>>=1){
			if(a&1){L=f(L,propagate(a));a++;}
			if(b&1){b--;R=f(propagate(b),R);}
		}
		st res=f(L,R);
		return res;
	}
	
	public:
	void init(int ns){
		V=1;
		while(V<=ns)V*=2;
		dat=new st[2*V];
		laz=new op[2*V];
		for(int i=0;i<2*V;i++){
			//dat[i]=st0;
			dat[i]=(st){0};
			laz[i]=op0;
		}
	}
	void update(ll l,ll r,ll a){
		upd(l,r,(op){a});
	}
	ll query(ll l,ll r){
		st res=qry(l,r);
		return res.a;
	}
};
Segtree seg;

int main(){
	int n,q;
	cin>>n>>q;
	seg.init(n);
	rep(i,n)seg.update(i,i,0);
	while(q--){
		ll p,s,t,x;
		cin>>p;
		if(p==0){
			cin>>s>>t>>x;
			seg.update(s,t,x);
		}
		if(p==1){
			cin>>s>>t;
			cout<<seg.query(s,t)<<"\n";
		}
	}
}