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 <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class LazySegmentTree {
    vector<int64_t> container;
    vector<int64_t> lazyContainer;

public:
    LazySegmentTree(int size)
        : container(msb1(size * 2 - 1))
        , lazyContainer(msb1(size * 2 - 1))
    {
    }

    void add(size_t s, size_t t, int64_t x)
    {
        add_inner(s, t, 0, container.size() / 2, 1, x);
    }

    int64_t find(size_t s, size_t t)
    {
        if (s >= t) {
            return 0;
        }
        return find_inner(s, t, 0, container.size() / 2, 1);
    }

    void debug()
    {
        for (int64_t i : container) {
            cout << i << "\t";
        }
        cout << endl;
        for (int64_t i : lazyContainer) {
            cout << i << "\t";
        }
        cout << endl;
    }

private:
    void add_inner(size_t s, size_t t, size_t lb, size_t ub, size_t node, int64_t x)
    {
        if (s == lb && t == ub) {
            lazyContainer[node] += x;
            maintain(node);
            return;
        }

        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            add_inner(s, min(mid, t), lb, mid, node * 2, x);
        }
        if (mid < t) {
            add_inner(max(mid, s), t, mid, ub, node * 2 + 1, x);
        }
        maintain(node * 2);
        maintain(node * 2 + 1);
        container[node] = min(container[node * 2], container[node * 2 + 1]);
    }

    int64_t find_inner(size_t s, size_t t, size_t lb, size_t ub, size_t node)
    {
        maintain(node);
        if (s == lb && t == ub) {
            return container[node];
        }

        int64_t result = numeric_limits<int64_t>::max();
        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            result = min(result, find_inner(s, min(mid, t), lb, mid, node * 2));
        }
        if (mid < t) {
            result = min(result, find_inner(max(s, mid), t, mid, ub, node * 2 + 1));
        }

        return result;
    }
    void maintain(size_t node)
    {
        container[node] += lazyContainer[node];
        size_t child = node * 2;
        if (child < container.size()) {
            lazyContainer[child] += lazyContainer[node];
            lazyContainer[child + 1] += lazyContainer[node];
        }
        lazyContainer[node] = 0;
    }
    int msb1(int x)
    {
        x |= x >> 1;
        x |= x >> 2;
        x |= x >> 4;
        x |= x >> 8;
        x |= x >> 16;

        return x + 1;
    }
};

int main()
{
    int n, q;
    cin >> n >> q;

    LazySegmentTree seg(n);

    rep(i, q)
    {
        int com;
        int s, t;
        cin >> com >> s >> t;
        if (com == 0) {
            int x;
            cin >> x;

            seg.add(s, t + 1, x);
        } else {
            cout << seg.find(s, t + 1) << endl;
        }
        //seg.debug();
    }
    return 0;
}
