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;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}
template<class T,class E,class F,class G,class H>
struct LazySegmentTree{
	F f;
	G g;
	H h;

	T ti;
	E ei;

	vector<T>dat;
	vector<E>put;
	int sz;
	LazySegmentTree(const T &ti,const E &ei,const F &f,const G &g,const H &h):ti(ti),ei(ei),f(f),g(g),h(h){}

	void build(const vector<T>&v){
		assert(v.size());
		sz=1;
		while(sz<v.size())sz<<=1;
		dat.resize(sz<<1,ti);
		put.resize(sz<<1,ei);
		for(int i=0;i<v.size();i++)dat[sz-1+i]=v[i];
		for(int i=sz-2;i>=0;i--)dat[i]=f(dat[i*2+1],dat[i*2+2]);
	}
	inline void push(int k,int l,int r){
		dat[k]=g(dat[k],put[k],r-l);
		if(k<sz-1){
			put[k*2+1]=h(put[k*2+1],put[k]);
			put[k*2+2]=h(put[k*2+2],put[k]);
		}
		put[k]=ei;
	}

	void modify(int a,int b,E x,int k,int l,int r){
		push(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			put[k]=x;
			push(k,l,r);
			return;
		}
		modify(a,b,x,k*2+1,l,(l+r)/2);
		modify(a,b,x,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}

	inline void modify(int a,int b,E x){
		return modify(a,b,x,0,0,sz);
	}
	T query(int a,int b,int k,int l,int r){
		push(k,l,r);
		if(r<=a||b<=l)return ti;
		if(a<=l&&r<=b)return dat[k];
		return f(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
	}
	inline T query(int a,int b){
		return query(a,b,0,0,sz);
	}
};

signed main(){
	auto f=[](int a,int b){return min(a,b);};
	auto g=[](int a,int b,int l){return a+b;};
	auto h=[](int a,int b){return a+b;};
	int ti=numeric_limits<int>::max();
	int ei=0;

	LazySegmentTree<int,int,decltype(f),decltype(g),decltype(h)>seg(ti,ei,f,g,h);

	int N,Q;
	scanf("%lld%lld",&N,&Q);
	seg.build(vint(N,0));
	while(Q--){
		int p,s,t,x;
		scanf("%lld%lld%lld",&p,&s,&t);
		t++;
		if(p==0){
			scanf("%lld",&x);
			seg.modify(s,t,x);
		}
		else{
			printf("%lld\n",seg.query(s,t));
		}
	}
	return 0;
}