Problem: Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

* update(s, t, x): change as, as+1, ..., at to x.
* find(s, t): report the minimum element in as, as+1, ..., at.



Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 0 ≤ s ≤ t < n
* 0 ≤ x < 231−1

Input


n q
query1
query2
:
queryq


In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi 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 update(s, t, x) and '1' denotes find(s, t).

Output

For each find operation, print the minimum value.

Examples

Input

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0 2
1 1 2


Output

1
2


Input

1 3
1 0 0
0 0 0 5
1 0 0


Output

2147483647
5

Solution (in CPP):

Solution:


#include "bits/stdc++.h"
#include <array>
using namespace std;

struct SgTree{
private:
	vector<pair<long long, bool>> node;
	long long defval;
	int N;
	int n;
public:
	void init(int n, long long defval = INT64_MAX){
		N = 1;
		while(N < n)N<<=1;
		this->n = n;
		this->defval = defval;
		node.assign(N*2-1, make_pair(defval, false));
	}
	long long query(int a, int b, int l = 0, int r = -1, int i = 0){
		if(r == -1) r = N;
		if(b <= l || r <= a) return defval;
		if(a <= l && r <= b) return node[i].first;
		if(node[i].second) return node[i].first;
		return min(query(a,b,l,(l+r)/2,i*2+1),query(a,b,(l+r)/2,r,i*2+2));
	}
	void update2(int a, int b, long long v, int l, int r, int i, long long defv){
		if(b <= l || r <= a) { node[i] = make_pair(defv, true); return; }
		if(a <= l && r <= b) { node[i] = make_pair(v, true); return; }
		
		update2(a,b,v,l,(l+r)/2,i*2+1,defv);
		update2(a,b,v,(l+r)/2,r,i*2+2,defv);

		node[i].second = false;
		node[i].first = min(node[i*2+1].first, node[i*2+2].first);
	}
	void update(int a, int b, long long v, int l = 0, int r = -1, int i = 0){
		if(r == -1) r = N;
		if(b <= l || r <= a) return;
		if(a <= l && r <= b) { node[i] = make_pair(v, true); return; }
		if(node[i].second) return update2(a,b,v,l,r,i,node[i].first);
		
		update(a,b,v,l,(l+r)/2,i*2+1);
		update(a,b,v,(l+r)/2,r,i*2+2);

		node[i].first = min(node[i*2+1].first, node[i*2+2].first);
	}

};


int main() {
	int n, q; cin >> n >> q;
	SgTree tr; tr.init(n, INT_MAX);

	vector<long long> ans;

	for(int i = 0; i < q; i++){
		int c; cin >> c;
		if(c == 0){
			int s,t,x; cin >> s >> t >> x;
			tr.update(s, t+1, x);
		}
		else {
			int s, t; cin >> s >> t;
			ans.push_back(tr.query(s, t+1));
		}
	}

	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}

    return 0;
}