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
#include <bits/stdc++.h>
using namespace std;

template<typename T, T max_v>
struct StarrySky{
    size_t n;
    vector<T> dat, lazy;

    StarrySky(vector<T> a){
        n = 1;
        while(n<a.size()) n <<= 1;
        dat.resize(2*n-1,max_v);
        lazy.resize(2*n-1,0);
        for(size_t i=0;i<a.size();i++) dat[i+n-1]=a[i];
        for(int i=n-2;i>=0;i--) dat[i]=min(dat[i*2+1],dat[i*2+2]);
    }

    inline void propagation(int k,int l,int r){
        dat[k]+=lazy[k];
        if((size_t)k<n-1){    // 最下段でない場合
            lazy[2*k+1]+=lazy[k];
            lazy[2*k+2]+=lazy[k];
        }
        lazy[k]=0;
    }

    // add to [a,b)
    void add(int a, int b, T x, int k, int l, int r){
        propagation(k,l,r);
        if(r<=a||b<=l) return; // no overlap area
        if(a<=l&&r<=b){ // [a,b) contains [l,r)
            lazy[k]+=x;
            propagation(k,l,r);
        }else{ // overlap
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }
    void add(int a,int b, T x){
        add(a,b,x,0,0,n);
    }

    // min of [a,b)
    T get(int a,int b,int k,int l,int r){
        propagation(k,l,r);
        if(r<=a||b<=l) return max_v;
        if(a<=l&&r<=b){ // [a,b) contains [l,r)
            return dat[k];
        }else{ // overlap
            T lv=get(a,b,2*k+1,l,(l+r)/2);
            T rv=get(a,b,2*k+2,(l+r)/2,r);
            return min(lv,rv);
        }
    }
    T get(int a,int b){
        return get(a,b,0,0,n);
    }
};

int main(){
    int n,q; cin >> n >> q;
    vector<long long> a(n,0);
    StarrySky<long long,(1LL<<60)> seg(a);
    for(int i=0;i<q;i++){
        int type; cin >> type;
        if(type == 0){
            int s,t,x; cin >> s >> t >> x;
            seg.add(s,t+1,x);
        }else{
            int s,t; cin >> s >> t;
            cout << seg.get(s,t+1) << endl;
        }
    }
}

