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:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
int const TREE_SIZE = 1 << 20;
long long int seg_tree[TREE_SIZE] = {};
long long int c_diff[TREE_SIZE] = {}; // 子との差

long long int find(int a, int b, int index, long long int diff, int l, int r){
	
	// [a, b) の最小値を求める
	
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return INF;
	}
	if(a <= l && r <= b){
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, find(a, b, index * 2, c_diff[index], l, (l + r) / 2));
	ret = min(ret, find(a, b, index * 2 + 1, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return ret;
}

long long int add(int a, int b, int index, long long int num, long long int diff, int l, int r){
	
	// [a, b) に num を足す
	
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		//cout << l << " " << r << " " << seg_tree[index] << " " << c_diff[index] << endl;
		return seg_tree[index];
	}
	if(a <= l && r <= b){
		seg_tree[index] += num;
		c_diff[index] += num;
		//cout << l << " " << r << " " << seg_tree[index] << " " << c_diff[index] << endl;
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, add(a, b, index * 2, num, c_diff[index], l, (l + r) / 2));
	ret = min(ret, add(a, b, index * 2 + 1, num, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	//cout << l << " " << r << " " << ret << endl;
	return seg_tree[index] = ret;
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 0; i < q; i++){
		long long int num, a, b, c;
		cin >> num;
		if(num == 0){
			cin >> a >> b >> c;
			add(a, b + 1, 1, c, 0, 0, TREE_SIZE / 2);
		}else{
			cin >> a >> b;
			cout << find(a, b + 1, 1, 0, 0, TREE_SIZE / 2) << endl;
		}
	}
	
	return 0;
}