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>
using namespace std;
typedef long long ll;

const int MAX_N = 1 << 17;

struct MinSegTree3 {
	int n;
	struct S {
		bool flag;
		int dat;
		S() : dat((1LL << 31) - 1), flag(false) {}
	};

	S node[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
	}

	void propagate(int k, int level) {
		if(!node[k].flag) return;
		node[k].flag = false;
		if(2 * k + 1 < 2 * n - 1) {
			S& t = node[k];
			S& l = node[2 * k + 1];
			S& r = node[2 * k + 2];
			l.flag = r.flag = true;
			l.dat = r.dat = t.dat;
		}
	}

	void update(int a, int b, int x) { update(a, b, x, 0, 0, 0, n); }

	void update(int a, int b, int x, int level, int k, int l, int r) {
		propagate(k, level);
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) {
			node[k].dat = x;
			node[k].flag = true;
			propagate(k, level);
			return;
		}
		update(a, b, x, level + 1, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, level + 1, k * 2 + 2, (l + r) / 2, r);
		// merge
		node[k].dat = min(node[2 * k + 1].dat, node[2 * k + 2].dat);
	}

	int query(int a, int b) { return query(a, b, 0, 0, 0, n); }

	int query(int a, int b, int level, int k, int l, int r) {
		propagate(k, level);
		if(r <= a || b <= l) return (1LL << 31) - 1;
		if(a <= l && r <= b) return node[k].dat;
		int vl = query(a, b, level + 1, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, level + 1, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

MinSegTree3 st;

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

	int n, q;
	cin >> n >> q;
	st.init(n);

	while(q--) {
		int a, s, t, x;
		cin >> a;
		if(a == 0) {
			cin >> s >> t >> x;
			st.update(s, t + 1, x);
		}
		else {
			cin >> s >> t;
			cout << st.query(s, t + 1) << endl;
		}
	}
}