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

template<class T, class E> struct LazySegmentTree {
    using F = function<T(T, T)>;
    using G = function<T(T, E)>;
    using H = function<E(E, E)>;
private : 
    int n, dep;
    const F f;
    const G g;
    const H h;
    T id1;
    E id0;
    vector<T> node;
    vector<E> lazy;

public : 
    LazySegmentTree (const F &f, const G &g, const H &h, const T &id1, const E &id0) :
        f(f), g(g), h(h), id1(id1), id0(id0) { }

    void init (int sz) {
        n = 1; dep = 0;
        while (n < sz) { n <<= 1; dep++; }
        node.resize(2*n, id1);
        lazy.resize(2*n, id0);
    }

    void build (vector<T> v) {
        const int sz = v.size();
        init(sz);
        for (int i = 0; i < sz; i++) node[i+n] = v[i];
        for (int i = n-1; i > 0; i--) node[i] = f(node[i<<1|0], node[i<<1|1]);
    }

    inline T reflect (int k) {
        return (lazy[k] == id0 ? node[k] : g(node[k], lazy[k]));
    }

    inline void eval (int k) {
        if (lazy[k] == id0) return;
        lazy[k<<1|0] = h(lazy[k<<1|0], lazy[k]);
        lazy[k<<1|1] = h(lazy[k<<1|1], lazy[k]);
        node[k] = reflect(k);
        lazy[k] = id0;
    }

    inline void thrust (int k) {
        for (int i = dep; i; i--) eval(k>>i);
    }

    inline void recalc (int k) {
        while (k >>= 1) node[k] = f(reflect(k<<1|0), reflect(k<<1|1));
    }

    void update (int a, int b, T x) {
        thrust(a += n);
        thrust(b += n-1);
        for (int l = a, r = b+1; l < r; l >>= 1, r >>= 1) {
            if (l&1) { lazy[l] = h(lazy[l], x); l++; }
            if (r&1) { --r; lazy[r] = h(lazy[r], x); }
        }
        recalc(a);
        recalc(b);
    }

    T query (int a, int b) {
        thrust(a += n);
        thrust(b += n-1);
        T vl = id1, vr = id1;
        for (int l = a, r = b+1; l < r; l >>= 1, r >>= 1) {
            if (l&1) vl = f(vl, reflect(l++));
            if (r&1) vr = f(reflect(--r), vr);
        }
        return f(vl, vr);
    }

};


int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    constexpr int INF = 1e9;
    
    int n, q;
    cin >> n >> q;
    auto f = [] (int a, int b) { return min(a, b); };
    auto g = [] (int a, int b) { return a + b; };
    auto h = [] (int a, int b) { return a + b; };
    LazySegmentTree<int, int> seg(f, g, h, INF, 0);
    seg.build(vector<int>(n, 0));
    
    while (q--) {
        int op, l, r;
        cin >> op >> l >> r;
        if (op) {
            cout << seg.query(l, ++r) << '\n';
        } else {
            int x;
            cin >> x;
            seg.update(l, ++r, x);
        }
    }
    return 0;
}