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 rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

//Starry-Sky木
//計算量 初期化:O(N)、区間加算:O(N)、区間min(max):O(N)、全体更新:O(N)

template<typename Monoid>
struct Starry_Sky_Tree{
    Monoid f(Monoid a, Monoid b){
        return min(a, b);
    }
    Monoid g(Monoid a, Monoid b){
        return a+b;
    }
    const Monoid unit, base = 0;
    int n;
    vector<Monoid> seg, lazy;
    
    Starry_Sky_Tree(int N, const Monoid &x) : unit(x){
        n = 1;
        while(n < N) n <<= 1;
        seg.assign(2*n, base);
        lazy.assign(2*n, base);
    }
    
    void add(int a, int b, const Monoid &x, int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return;
        if(a <= l && r <= b){
            lazy[i] = g(lazy[i], x);
            return;
        }
        add(a, b, x, 2*i, l, (l+r)/2);
        add(a, b, x, 2*i+1, (l+r)/2, r);
        seg[i] = f(g(seg[2*i], lazy[2*i]), g(seg[2*i+1], lazy[2*i+1]));
    }
    
    Monoid query(int a, int b, int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return unit;
        if(a <= l && r <= b) return g(seg[i], lazy[i]);
        Monoid vl = query(a, b, 2*i, l, (l+r)/2);
        Monoid vr = query(a, b, 2*i+1, (l+r)/2, r);
        return g(f(vl, vr), lazy[i]);
    }
    
    void update(int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        seg[i] = g(seg[i], lazy[i]);
        if(r-l > 1){
            lazy[2*i] = g(lazy[2*i], lazy[i]);
            lazy[2*i+1] = g(lazy[2*i+1], lazy[i]);
            update(2*i, l, (l+r)/2);
            update(2*i+1, (l+r)/2, r);
        }
        lazy[i] = base;
    }
    
    Monoid operator [] (int i) const {return seg[n+i];}
    
    void clear(){
        fill(seg.begin(), seg.end(), base);
        fill(lazy.begin(), lazy.end(), base);
    }
};

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_H

int main(){
    int N, Q;
    cin >> N >> Q;
    Starry_Sky_Tree<int> seg(N, inf);
    while(Q--){
        int q, x, y; cin >> q >> x >> y; y++;
        if(q == 0){
            ll a; cin >> a;
            seg.add(x, y, a);
        }
        else cout << seg.query(x, y) << endl;
    }
}
