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;
int N, N_, Q; 
long long seg[524300], lazy[524300]; 
void init(int N_){
	N = 1; 
	while(N < N_) N *= 2; 
	for(int i = 0; i < N * 2 - 1; i++){
		seg[i] = 0; lazy[i] = 0;  
	}
}
void update(int k){
	if(lazy[k] == 0) return; 
	seg[k] += lazy[k]; 
	if(k * 2 + 2 < N * 2 - 1){
		lazy[k * 2 + 1] += lazy[k]; 
		lazy[k * 2 + 2] += lazy[k]; 
	}
	lazy[k] = 0; 
}
void add(int a, int b, int k, int l, int r, long long x){
	update(k); 	
	if(b <= l || r <= a) return; 
	if(a <= l && r <= b){
		lazy[k] += x; 
		update(k); 
	}else{
		add(a, b, k * 2 + 1, l, (l+r)/2, x);
		add(a, b, k * 2 + 2, (l+r)/2, r, x);
		seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
	}
}
long long query(int a, int b, int k, int l, int r){
	if(b <= l || r <= a) return 1145141919810364364LL; 
	update(k); 
	if(a <= l && r <= b) return seg[k];
	long long vl = query(a, b, k * 2 + 1, l, (l+r)/2);
	long long vr = query(a, b, k * 2 + 2, (l+r)/2, r);
	return min(vl, vr); 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N_ >> Q;
	init(N_);
	while(Q--){
		int a; cin >> a; 
		if(a == 0){
			int s, t; long long x; 
			cin >> s >> t >> x; 
			add(s, t+1, 0, 0, N, x);
		}else if(a == 1){
			int s, t; cin >> s >> t;
			cout << query(s, t+1, 0, 0, N) << "\n"; 
		}	
	}
}