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>
using namespace std;
#include <vector>
#include <functional>
template<class T, class Lazy> struct LazySegTree {
  private:
  public:
    int size;
    vector<T> v; vector<Lazy> lazy;
    vector<int> seg_size;
    using F = function<T(T,T)>;
    using G = function<Lazy(Lazy,Lazy)>;
    using H = function<T(T,Lazy,int)>;
    F f; G g; H h;
    T default_value; Lazy default_lazy;
  public:
    LazySegTree(int n, T default_value, Lazy default_lazy, F f, G g, H h)
      : default_value(default_value), default_lazy(default_lazy), f(f), g(g), h(h) {
      size = 1;
      while (size < n) size *= 2;

      v.resize(2 * size - 1, default_value);
      lazy.resize(4 * size - 1, default_lazy);
      seg_size.resize(2 * size - 1, 1);

      for (int i = 0; i < size - 1; ++i) {
        int j = size - 2 - i;
        seg_size[j] = seg_size[2 * j + 1] + seg_size[2 * j + 2];
      }
    }
    void update(int index, T val) {
      update(index, index+1, default_lazy);
      index = index + size - 1;
      v[index] = val;
      while (index > 0) {
        index = (index - 1) / 2;
        v[index] = f(v[2 * index + 1], v[2 * index + 2]);
      }
    }
    void eval(int index) {
      v[index] = h(v[index], lazy[index], seg_size[index]);

      lazy[2 * index + 1] = g(lazy[index], lazy[2 * index + 1]);
      lazy[2 * index + 2] = g(lazy[index], lazy[2 * index + 2]);

      lazy[index] = default_lazy;
    }
    T query(int l, int r) { return query(l, r, 0, size, 0); }
    T query(int l, int r, int cur_l, int cur_r, int index) {
      // [l, r)に対するクエリ
      eval(index);
      if (cur_r <= l || r <= cur_l) return default_value;
      if (l <= cur_l && cur_r <= r) return v[index];

      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      return f(
          query(l, r, cur_l, mid, 2 * index + 1),
          query(l, r, mid, cur_r, 2 * index + 2));
    }
    void update(int l, int r, Lazy x) { update(l, r, x, 0, size, 0); }
    void update(int l, int r, Lazy x, int cur_l, int cur_r, int index) {
      // [l, r)に対して操作する

      eval(index);
      if (cur_r <= l || r <= cur_l) return;
      if (l <= cur_l && cur_r <= r) {
        lazy[index] = x;
        eval(index);
        return;
      }
      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      update(l, r, x, cur_l, mid, 2 * index + 1);
      update(l, r, x, mid, cur_r, 2 * index + 2);
      v[index] = f(v[2 * index + 1], v[2 * index + 2]);
    }
};

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int in(N); int in(Q);

  // 範囲和
  LazySegTree<long long, long long> T(N, 1e12, 0,
      [](long long a, long long b) {return min(a, b);},
      [](long long a, long long b) {return a + b;},
      [](long long a, long long b, int size) {return a + b;});

  rep(i, N) {
    T.update(i, i+1, -1e12);
    T.query(i, i+1);
  }

  rep(i, Q) {
    int com, s, t;
    ins(com, s, t);
    ++t;

    if (com == 0) {
      int in(x);
      T.update(s, t, x);
    } else
      cout << T.query(s, t) << endl;
  }

  return 0;
}