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;
typedef long long ll;
const int maxn=100005;

int n,q;
bool tag[4*maxn];
ll S[4*maxn],lazy[4*maxn];

void upd(int id,int l,int r,int ql,int qr,int v) {
    if (ql==l && qr==r) {
        tag[id]=1;
        lazy[id]+=v;
        return;
    }
    if (tag[id]) {
        S[id]+=lazy[id];
        if (l!=r) {
            tag[id<<1]=1;
            tag[id<<1|1]=1;
            lazy[id<<1]+=lazy[id];
            lazy[id<<1|1]+=lazy[id];
        }
        tag[id]=0;
        lazy[id]=0;
    }
    int m=l+r>>1;
    if (qr<=m) upd(id<<1,l,m,ql,qr,v);
    else if (ql>m) upd(id<<1|1,m+1,r,ql,qr,v);
    else upd(id<<1,l,m,ql,m,v),
         upd(id<<1|1,m+1,r,m+1,qr,v);
    ll lm=S[id<<1]; if (tag[id<<1]) lm+=lazy[id<<1];
    ll rm=S[id<<1|1]; if (tag[id<<1|1]) rm+=lazy[id<<1|1];
    S[id]=min(lm,rm);
}

ll query(int id,int l,int r,int ql,int qr) {
    if (tag[id]) {
        S[id]+=lazy[id];
        if (l!=r) {
            tag[id<<1]=1;
            tag[id<<1|1]=1;
            lazy[id<<1]+=lazy[id];
            lazy[id<<1|1]+=lazy[id];
        }
        tag[id]=0;
        lazy[id]=0;
    }
    if (ql==l && qr==r) return S[id];
    int m=l+r>>1;
    if (qr<=m) return query(id<<1,l,m,ql,qr);
    else if (ql>m) return query(id<<1|1,m+1,r,ql,qr);
    else return min(query(id<<1,l,m,ql,m),query(id<<1|1,m+1,r,m+1,qr));
}

int main() {
    cin>>n>>q;
    for (int i=0;i<q;i++) {
        int f,s,t,x; cin>>f>>s>>t;
        if (f) cout<<query(1,0,n-1,s,t)<<'\n';
        else {
            cin>>x;
            upd(1,0,n-1,s,t,x);
        }
    }
}