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;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

const int DAT_SIZE=1<<18;
const int MAX_N=100050;

int N;
vll datadd(DAT_SIZE),datmin(DAT_SIZE);//datadd:その区間に一様に加算される値を持つ, datamin:その区間の最小値を持つ
vll a(MAX_N);

//[a,b)にxを加算
//0-indexであることに注意
void add(int a,int b,ll x,int k,int l,int r){
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b)datadd[k]+=x;
    else if(l<b&&a<r){
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        datmin[k]=min(datmin[2*k+1]+datadd[2*k+1],datmin[2*k+2]+datadd[2*k+2]);
    }
}

//初期化
void init(int n){
    N=1;
    while(N<n)N*=2;
    //rep(i,n)add(i,i+1,a[i],0,0,n);
}

ll getmin(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return datmin[k]+datadd[k];
    ll chl=getmin(a,b,2*k+1,l,(l+r)/2);
    ll chr=getmin(a,b,2*k+2,(l+r)/2,r);
    return min(chl,chr)+datadd[k];
}

int main(){
    int n,q;cin>>n>>q;
    init(n);
    vll ans;
    int c,s,t;ll x;
    rep(i,q){
        cin>>c>>s>>t;
        if(c==0){
            cin>>x;
            add(s,t+1,x,0,0,N);
        }
        else ans.push_back(getmin(s,t+1,0,0,N));
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
}