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>
struct segtree_lazy {
	int n;
	vector<T> tree, lazy;
	T def = numeric_limits<T>::max(), none = numeric_limits<T>::max();
	
	segtree_lazy(int n_) {
		for (n = 1; n < n_; n *= 2) {
			
		}
		tree.assign(2 * n, def);
		lazy.assign(2 * n, none);
	}
	
	T merge(T a, T b) {
		return min(a, b);
	}
	
	void set_lazy(int index, T x) {
		tree[index] = x;
		lazy[index] = x;
	}
	
	void push(int index) {
		if (lazy[index] == none) {
			return;
		}
		set_lazy(2 * index, lazy[index]);
		set_lazy(2 * index + 1, lazy[index]);
		lazy[index] = none;
	}
	
	void fix(int index) {
		tree[index] = merge(tree[2 * index], tree[2 * index + 1]);
	}
	
	void update(int a, int b, int index, int l, int r, T x) {
		if (r <= a || b <= l) {
			return;
		}
		if (a <= l && r <= b) {
			set_lazy(index, x);
			return;
		}
		push(index);
		update(a, b, 2 * index, l, (l + r) / 2, x);
		update(a, b, 2 * index + 1, (l + r) / 2, r, x);
		fix(index);
	}
	
	void update(int l, int r, T x) {
		update(l, r, 1, 0, n, x);
	}
	
	T query(int a, int b, int index, int l, int r) {
		if (r <= a || b <= l) {
			return none;
		}
		if (a <= l && r <= b) {
			return tree[index];
		}
		push(index);
		T puni = query(a, b, 2 * index, l, (l + r) / 2);
		T muni = query(a, b, 2 * index + 1, (l + r) / 2, r);
		return merge(puni, muni);
	}
	
	T query(int l, int r) {
		return query(l, r, 1, 0, n);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	segtree_lazy<int> seg(n);
	for (int i = 0; i < q; i++) {
		bool b;
		cin >> b;
		if (b) {
			int s, t;
			cin >> s >> t;
			cout << seg.query(s, t + 1) << endl;
		} else {
			int s, t, x;
			cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}