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 <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

struct LazySegmentTree{
    vector<int> data;
    vector<int> lazy;
    int sz;

    LazySegmentTree(int n){
        sz = 1;
        while(sz < n)   sz <<= 1;
        data.assign(sz << 1, 0);
        lazy.assign(sz << 1, 0);
    }

    void set(int k, const int& x) { data[sz + k] = x; }
    void build(){
        for(int k = sz - 1; k >= 0; --k){
            data[k] = min(data[k], data[k << 1 | 1]);
        }
    }

    void propagate(int k){
        if(lazy[k] != 0){
            data[k] += lazy[k];
            if(k < sz){
                lazy[k << 1] += lazy[k];
                lazy[k << 1 | 1] += lazy[k];
            }
            lazy[k] = 0;
        }
        return;
    }

    int update(int a, int b, const int& x, int k = 1, int l = 0, int r = -1){
        if(r == -1) r = sz;
        propagate(k);
        if(b <= l || r <= a)    return data[k];
        else if(a <= l && r <= b){
            lazy[k] += x;
            propagate(k);
            return data[k];
        }
        else{
            return data[k] = min(update(a, b, x, k << 1, l, (l + r) >> 1),
                                update(a, b, x, k << 1 | 1, (l + r) >> 1, r));
        }
    }

    int query(int a, int b, int k = 1, int l = 0, int r = -1){
        if(r == -1) r = sz;
        propagate(k);
        if(b <= l || r <= a)    return INF;
        else if(a <= l && r <= b)   return data[k];
        else{
            return min(query(a, b, k << 1, l, (l + r) >> 1),
                        query(a, b, k << 1 | 1, (l + r) >> 1, r));
        }
    }
};

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

    int n, q;
    cin >> n >> q;
    LazySegmentTree seg(n);
    for(int i = 0; i < q; ++i){
        int com;
        cin >> com;
        if(!com){
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t + 1, x);
        }
        else{
            int s, t;
            cin >> s >> t;
            cout << seg.query(s, t + 1) << '\n';
        }
    }
}
