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:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct SegTree {
    int n;
    vll data;
    vll lazy;

    SegTree(int m) {
        n = 1;
        while(n < m) n *= 2;
        data = vll(2 * this->n - 1, 0); // need to change
        lazy = vll(2 * this->n - 1, 0);  // need to change
    }

    void eval(int k) {
        if(lazy[k] == 0) return;    // need to change
        if(k < n - 1) {
            lazy[k * 2 + 1] += lazy[k];  // need to change
            lazy[k * 2 + 2] += lazy[k];  // need to change
        }
        data[k] += lazy[k];  // need to change
        lazy[k] = 0; // need to change
    }

    void update(int a, int b, ll x, int k, int l, int r) {
        eval(k);
        if(a <= l && r <= b) {
            lazy[k] += x;    // need to change
            eval(k);
        }
        else if(a < r && l < b) {
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);
            data[k] = min(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    void update(int a, int b, ll x) {   // update for [a, b)
        update(a, b, x, 0, 0, n);
    }

    ll query(int a, int b, int k, int l, int r) {
        eval(k);
        if(r <= a || b <= l) {
            return INFL;    // need to change
        }
        if(a <= l && r <= b) {
            return data[k];
        }
        else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr); // need to change
        }
    }

    ll query(int a, int b) {
        return query(a, b, 0, 0, n);   // query for [a, b)
    }
};

void solve() {
    ll n, q;
    cin >> n >> q;
    SegTree st(n);
    vll ans;
    for(ll i = 0; i < q; i++) {
        ll c;
        cin >> c;
        if(c == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            st.update(s, t + 1, x);
        }
        else {
            ll s, t;
            cin >> s >> t;
            ans.push_back(st.query(s, t + 1));
        }
    }
    for(auto i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}