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 <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

struct LzyST {
  ll n;
  vll dat, laz;
  LzyST() {}
  LzyST(ll n_) { init(n_); }
  void init(ll n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.clear();
    dat.resize(2 * n - 1, 0);
    laz.clear();
    laz.resize(2 * n - 1, 0);
  }

  inline void eval(ll k) {
    if (laz[k] == 0) return;
    if (k * 2 + 1 < n * 2 - 1) {
      laz[k * 2 + 1] += laz[k];
      laz[k * 2 + 2] += laz[k];
    }
    dat[k] += laz[k];
    laz[k] = 0;
  }
  void add(ll a, ll b, ll x, ll k, ll l, ll r) {
    eval(k);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      laz[k] = x;
      eval(k);
      return;
    }
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    dat[k] = min(dat[2*k+1], dat[2*k+2]);
    return;
  }
  ll find(ll a, ll b, ll k, ll l, ll r) {
    if (r <= a || b <= l) return INF;
    eval(k);    
    if (a <= l && r <= b) return dat[k];
    ll vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
  void add(ll a, ll b, ll x) { add(a, b + 1, x, 0, 0, n); }
  ll find(ll a, ll b) { return find(a, b + 1, 0, 0, n); }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, q;
  cin >> n >> q;
  LzyST lst(n);
  for (ll i = 0; i < q; i++) {
    ll c;
    cin >> c;
    if (c == 0) {
      ll s, t, x;
      cin >> s >> t >> x;
      lst.add(s, t, x);
    } else {
      ll s, t;
      cin >> s >> t;
      cout << lst.find(s, t) << endl;
    }
  }

  return 0;
}