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;

template <typename T>
class LazySegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id1, id2;
	func_t merge;
	func_t change;
	vector<T> data, lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void propa(int node) {
		if (lazy[node] == id2) return;
		if (node < n) {
			lazy[node * 2] = change(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = change(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = change(data[node], lazy[node]);
		lazy[node] = id2;
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		propa(node);
		if (l <= lb && ub <= r) {
			lazy[node] = val;
			return;
		}
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = merge(change(data[node * 2], lazy[node * 2]), change(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id1;
		propa(node);
		if (l <= lb && ub <= r) {
			return data[node];
		}
		int c = (lb + ub) / 2;
		return merge(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_, T id1_, T id2_, func_t merge_, func_t change_)
		: n(size(n_)), id1(id1_), id2(id2_), merge(merge_), change(change_), data(n * 2, id1), lazy(n * 2, id2) {}
	void update(int l, int r, T val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q, com, s, t, x;
	cin >> n >> q;
	LazySegmentTree<int> lst(n, INT_MAX, -1, [](int l, int r) { return min(l, r); }, [](int l, int r) { return r != -1 ? r : l; });
	while (q--) {
		cin >> com;
		if (com) {
			cin >> s >> t;
			printf("%d\n", lst.find(s, t));
		}
		else {
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}