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 <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;




const int MAX_N = 110000;
const int INF = 1LL<<30;

typedef int VAL;     // モノイドの型
typedef int DELAY;   // 作用 (遅延評価) の型

const VAL UNITY_VAL = INF;    // モノイドの単位元
const DELAY UNITY_DELAY = 0;  // 作用の単位元

static int SIZE_SEG;
struct SegTree {
  VAL val[4*MAX_N];  
  DELAY delay[4*MAX_N]; 

  SegTree(int n = MAX_N, VAL v = UNITY_VAL) {
	init(n, v);
  }
    
  void init(int n = MAX_N, VAL v = UNITY_VAL) {
	SIZE_SEG = 1;
	while (SIZE_SEG < n) SIZE_SEG *= 2;
	for (int i = 0; i < 2*SIZE_SEG-1; ++i) val[i] = v, delay[i] = UNITY_DELAY;
  }


  ///////////////////////////////
  // モノイド演算の定義、作用の定義: ここだけ書き換えれば OK
  ///////////////////////////////

  // モノイド演算
  inline VAL merge(VAL a, VAL b) {

	// Starry Sky Tree の場合: min
	VAL res = min(a, b);
	return res;
  }

  // 作用元での演算
  inline void add(DELAY &d, DELAY x) {

	// Starry Sky Tree の場合: +
    d += x;
  }

  // モノイドへの作用
  inline void reflect(VAL &a, DELAY d) {

	// Starry Sky Tree の場合: 加算
	a += d;
  }


  ///////////////////////////////
  // ここから下は書き換え不要！！！
  ///////////////////////////////
    
  inline void redelay(int k, int l, int r) {
	reflect(val[k], delay[k]);
	if (k < SIZE_SEG-1) {
	  add(delay[k*2+1], delay[k]);
	  add(delay[k*2+2], delay[k]);
	}
	delay[k] = UNITY_DELAY;
  }
    
  inline void renode(int k, int l, int r) {
	val[k] = merge(val[k*2+1], val[k*2+2]);
  }
    
  inline void set(int a, int b, DELAY x, int k = 0, int l = 0, int r = SIZE_SEG) {
	if (a <= l && r <= b) {                 // included
	  add(delay[k], x);
	  redelay(k, l, r);
	}
	else if (a < r && l < b) {              // intersected
	  redelay(k, l, r);
	  set(a, b, x, k*2+1, l, (l+r)/2);
	  set(a, b, x, k*2+2, (l+r)/2, r);
	  renode(k, l, r);
	}
	else {                                  // no-intersected
	  redelay(k, l, r);
	}
  }
    
  inline VAL get(int a, int b, int k = 0, int l = 0, int r = SIZE_SEG) {
	redelay(k, l, r);
	if (a <= l && r <= b) {                 // included
	  return val[k];
	}
	else if (a < r && l < b) {              // intersected
	  VAL t1 = get(a, b, k*2+1, l, (l+r)/2);
	  VAL t2 = get(a, b, k*2+2, (l+r)/2, r);
	  renode(k, l, r);
      
	  return merge(t1, t2);
	}
	else {                                  // no-intersected
	  return UNITY_VAL;
	}
  }

  /*
  inline VAL operator [] (int i) {return get(i, i+1);}
  
  void print(long long r = SIZE_SEG) {
	long long t = 2;
	for (int i = 0; i < r*2-1; ++i) {
	  cout << make_pair(val[i], delay[i]) << ",";
	  if (i == t-2) {cout << endl; t *= 2;}
	}
	for (int i = 0; i < r; ++i) {
	  cout << get(i, i+1) << ", ";
	}
	cout << endl << endl;
  }
  */
};



int main() {
  int n, q;
  cin >> n >> q;
  SegTree seg(n, 0);
  for (int i = 0; i < q; ++i) {
	int type, left, right;
	cin >> type >> left >> right;
	if (type == 0) {
	  int val;
	  cin >> val;
	  seg.set(left, right+1, val);
	}
	else {
	  int res = seg.get(left, right+1);
	  cout << res << endl;
	}
  }
}