#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll MOD = 1e9 + 7;


//↓遅延セグ木ここから
//↓変える
typedef struct sayouso { ll p,q; }sayouso;
typedef struct atai { ll a; }atai;
//↑変える
typedef struct node { sayouso T; atai x; }node;

vector<node>lsegN;
ll lsegNUM, lsegk;

//↓変える
sayouso id = { 1 , 0 };
atai xx(atai x, atai y) {
	atai ret;
	ret.a = min(x.a,y.a);
	return ret;
}
atai Tx(sayouso T, atai x) {
	atai ret;
	ret.a = (T.p*x.a + T.q);
	return ret;
}
sayouso TT(sayouso S, sayouso T) {
	sayouso ret;
	ret.p = S.p * T.p;
	ret.q = S.p*T.q + S.q;
	return ret;
}
sayouso fT(sayouso T, ll k) {
	sayouso ret;
	ret.p = T.p;
	ret.q = T.q;
	return ret;
}
//↑ここまで変える

void lseguse(ll n) {
	lsegNUM = 1;
	lsegk = 0;
	while (lsegNUM < n) {
		lsegNUM *= 2LL;
		lsegk++;
	}
	lsegN.resize(2 * lsegNUM);
}


void lseginit() {
	for (ll i = lsegNUM - 1; i > 0; i--)lsegN[i].x = xx(lsegN[2 * i].x, lsegN[2 * i + 1].x);
	for (ll i = 0; i < 2LL * lsegNUM; i++)lsegN[i].T = id;
}

//debug
void pr(){
	fore(p, lsegN)cout << p.x.a << " ";
	cout << endl;
}

void _update(ll l, ll r, sayouso T, ll i, ll cl, ll cr, ll ck) {
	//区間が含まれていないときは何もしない
	if (cr <= l || r <= cl)return;
	//完全に含まれているときは区間全体に作用素を作用させて良い
	if (l <= cl && cr <= r) {
		lsegN[i].T = TT(T, lsegN[i].T);
		return;
	}
	//遅延伝搬
	lsegN[2 * i].T = TT(lsegN[i].T, lsegN[2 * i].T);
	lsegN[2 * i + 1].T = TT(lsegN[i].T, lsegN[2 * i + 1].T);
	//子ノードを再帰的に更新していく
	ll cm = (cl + cr) / 2;
	_update(l, r, T, 2 * i, cl, cm, ck - 1);
	_update(l, r, T, 2 * i + 1, cm, cr, ck - 1);
	//↑の更新を基に現在のnodeの値を更新
	lsegN[i].x = xx(Tx(fT(lsegN[2 * i].T, ck - 1), lsegN[2 * i].x), Tx(fT(lsegN[2 * i + 1].T, ck - 1), lsegN[2 * i + 1].x));
	lsegN[i].T = id;
}
void update(ll l, ll r, sayouso T) { _update(l, r, T, 1, 0, lsegNUM, lsegk); }
atai _calc(ll l, ll r, ll i, ll cl, ll cr, ll ck) {
	//完全に含まれているときは区間全体に作用素を作用させて良い
	if (l <= cl && cr <= r) {
		return Tx(fT(lsegN[i].T, ck), lsegN[i].x);
	}
	ll cm = (cl + cr) / 2;
	lsegN[2 * i].T = TT(lsegN[i].T, lsegN[2 * i].T);
	lsegN[2 * i + 1].T = TT(lsegN[i].T, lsegN[2 * i + 1].T);
	lsegN[i].x = Tx(fT(lsegN[i].T, ck), lsegN[i].x);
	lsegN[i].T = id;
	//このように分けて返すことにより、モノイドの単位元を返す必要がなくなる
	if (r <= cm)return _calc(l, r, 2 * i, cl, cm, ck - 1);
	if (cm <= l)return _calc(l, r, 2 * i + 1, cm, cr, ck - 1);
	return xx(_calc(l, r, 2 * i, cl, cm, ck - 1), _calc(l, r, 2 * i + 1, cm, cr, ck - 1));
}
atai calc(ll l, ll r) { return _calc(l, r, 1, 0, lsegNUM, lsegk); };
//↑遅延セグ木ここまで



int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, Q;
	cin >> N >> Q;
	lseguse(N);
	for (int i = 0; i < lsegNUM; i++)lsegN[i + lsegNUM].x.a = (1LL << 31) - 1;
	lseginit();

	for (int i = 0; i < Q; i++) {
		int q, s, t, x;
		cin >> q;
		if (q == 0) {
			cin >> s >> t >> x;
			sayouso T;
			T.p = 0;
			T.q = x;
			update(s, t + 1, T);
		}
		else {
			cin >> s >> t;
			puts(calc(s, t + 1).a);
		}
	}
	return 0;
}


Measured memory_bytes: 8896