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>

class SegmentTree {
private:
	std::vector<int64_t> sumContainer_, minContainer_;

	void lazyEvaluate(const int node_i)
	{
		minContainer_[node_i] += sumContainer_[node_i];
		if (node_i < ((int)sumContainer_.size() >> 1))
		{
			sumContainer_[2 * node_i] += sumContainer_[node_i];
			sumContainer_[2 * node_i + 1] += sumContainer_[node_i];
		}
		sumContainer_[node_i] = 0;
	}

	void addImplement(const int query_l, const int query_r, const int node_l, const int node_r, const int node_i, const int64_t added)
	{
		if (query_l <= node_l && node_r <= query_r)
		{
			sumContainer_[node_i] += added;
			lazyEvaluate(node_i);
			return;
		}
		lazyEvaluate(node_i);
		if (node_r <= query_l || query_r <= node_l) return;
		const int node_m{(node_l + node_r) >> 1};
		addImplement(query_l, query_r, node_l, node_m, 2 * node_i, added);
		addImplement(query_l, query_r, node_m, node_r, 2 * node_i + 1, added);
		minContainer_[node_i] = std::min(minContainer_[2 * node_i], minContainer_[2 * node_i + 1]);
	}

	int64_t findImplement(const int query_l, const int query_r, const int node_l, const int node_r, const int node_i)
	{
		if (node_r <= query_l || query_r <= node_l) return LLONG_MAX;
		lazyEvaluate(node_i);
		if (query_l <= node_l && node_r <= query_r) return minContainer_[node_i];
		const int node_m{(node_l + node_r) >> 1};
		return std::min(
			findImplement(query_l, query_r, node_l, node_m, 2 * node_i),
			findImplement(query_l, query_r, node_m, node_r, 2 * node_i + 1)
		);
	}
public:
	SegmentTree(const int n)
	{
		int size{1};
		while (size < n) size <<= 1;
		sumContainer_.resize(2 * size);
		minContainer_.resize(2 * size);
	}

	void add(const int left, const int right, int64_t added)
	{
		addImplement(left, right, 0, sumContainer_.size() >> 1, 1, added);
	}

	int64_t find(const int left, const int right)
	{
		return findImplement(left, right, 0, sumContainer_.size() >> 1, 1);
	}
};

int main()
{
	int n, q;
	scanf("%d%d", &n, &q);
	SegmentTree st(n);
	for (int q_i{}; q_i < q; q_i++)
	{
		int query, s, t;
		scanf("%d%d%d", &query, &s, &t);
		t++;
		if (query == 0)
		{
			int x;
			scanf("%d", &x);
			st.add(s, t, x);
		}
		else
			printf("%lld\n", st.find(s, t));
	}
	return 0;
}