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<bits/stdc++.h>
using namespace std;

using lint = long long;


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, q;
    cin >> n >> q;
    const int S = 1<<18;
	vector<int> seg(2*S), lazy(2*S);
    // for (int i = 1; i <= n; ++i)
    // 	seg[i+S] = i;
    int h = __builtin_clz(1)-__builtin_clz(S);
    auto apply = [&](int v, int delta) {
		seg[v] += delta;
		if (v < S) lazy[v] += delta;
	};
	auto push = [&] (int v) {
		for (int s = h; s > 0; --s) {
			int i = v >> s;
			if (lazy[i]) {
				apply(2*i, lazy[i]);
				apply(2*i+1, lazy[i]);
				lazy[i] = 0;
			}
		}
	};
	auto update_all = [&](int v) {
		while(v /= 2) {
			seg[v] = min(seg[2*v], seg[2*v+1]);
			seg[v] += lazy[v];
		}
	};

	auto update = [&](int l, int r, int delta) {
		push(l + S), push(r + S - 1);
		for (int a = l+S, b = r+S; a < b; a /= 2, b /= 2) {
			if (a & 1) apply(a++, delta);
			if (b & 1) apply(--b, delta);
		}
		update_all(l + S), update_all(r + S - 1);
	};

	auto query = [&](int l, int r) {
		push(l + S), push(r + S - 1);
		int res = INT_MAX/2;
		for (int a = l+S, b = r+S; a < b; a /= 2, b /= 2) {
			if (a & 1) res = min(res, seg[a++]);
			if (b & 1) res = min(res, seg[--b]);
		}
		return res;
	};
    // for (int i = S; i; --i) seg[i] = (seg[2*i] + seg[2*i+1]);
    while(q--) {
    	int op, l, r;
    	cin >> op >> l >> r;
    	--l, --r;
    	if (op) {
    		cout << query(l, r+1) << '\n';
    	}
    	else {
    		int v;
    		cin >> v;
    		update(l, r+1, v);
    	}
    	// for (int i = 0; i < n; ++i) {
	    // 	cout << query(i, i+1) << ' ';
	    // }
	    // cout << endl;
    }
    
}