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>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, q, s, t, x, u, a[1 << 18], b[1 << 18];
bool f;

void add(int k, int l, int r) {
	if (!(t < l || r < s)) {
		if (s <= l&&r <= t) {
			a[k] += x;
			b[k] += x;
		}
		else {
			add(k * 2, l, (l + r) / 2);
			add(k * 2 + 1, (l + r) / 2 + 1, r);
			a[k * 2] += b[k];
			a[k * 2 + 1] += b[k];
			b[k * 2] += b[k];
			b[k * 2 + 1] += b[k];
			b[k] = 0;
			a[k] = min(a[k * 2], a[k * 2 + 1]);
		}
	}
}

int find(int k, int l, int r) {
	if (t < l || r < s)return intmax;
	else if (s <= l&&r <= t)
		return a[k];
	else {
		a[k * 2] += b[k];
		a[k * 2 + 1] += b[k];
		b[k * 2] += b[k];
		b[k * 2 + 1] += b[k];
		b[k] = 0;
		a[k] = min(a[k * 2], a[k * 2 + 1]);
		return min(find(k * 2, l, (l + r) / 2), find(k * 2 + 1, (l + r) / 2 + 1, r));
	}
}

int main(){
	cin >> n >> q;
	for (u = 1; u < n; u *= 2);
	--u;
	for (int i = 0; i != q; ++i) {
		cin >> f >> s >> t;
		if (f)
			cout << find(1, 0, u) << endl;
		else {
			cin >> x;
			add(1, 0, u);
		}
	}
	return 0;
}