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;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

struct SegmentTree{
    SegmentTree(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
    }
    void propagate(int k){
        if(data2[k] != 0){
            data[k] += data2[k];
            if(k < size){
                data2[k*2] += data2[k];
                data2[k*2+1] += data2[k];
            }
            data2[k] = 0;
        }
    }
    void update(int l, int r, ll x){
        _update(1, 0, size, l, r, x);
    }
    inline void _update(int k, int a, int b, int l, int r, ll x){
        propagate(k);

        if(b <= l || r <= a){return;}
        if(l <= a && b <= r){
            data2[k] = x;
            propagate(k);
        }else{
            int mid = (a + b) / 2;
            _update(k * 2, a, mid, l, r, x);
            _update(k * 2 + 1, mid, b, l, r, x);
            data[k] = std::min(data[k*2], data[k*2+1]);
        }
    }
    ll minimum(int l, int r){
        return _minimum(1, 0, size, l, r);
    }
    inline ll _minimum(int k, int a, int b, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return D;}
        if(l <= a && b <= r){return data[k];}
        int mid = (a + b) / 2;
        ll vl = _minimum(k * 2, a, mid, l, r),
            vr = _minimum(k * 2 + 1, mid, b, l, r);
        return std::min(vl, vr);
    }
    
    int size;
    ll data[400100], data2[400100];
    const ll D = numeric_limits<ll>::max() / 2;
};

int N, Q;
SegmentTree segtree(100000);

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N >> Q;

    for(int i=0;i<Q;++i){
        int type, s, t;

        std::cin >> type >> s >> t;

        if(type == 0){
            ll x;
            std::cin >> x;

            segtree.update(s, t + 1, x);
        }else{
            std::cout << segtree.minimum(s, t + 1) << std::endl;
        }
    }
}

