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 <iostream>
#include <algorithm>
using namespace std;

const int DEPTH = 17;
const int INTMAX = (1LL << 31) - 1;

struct SegTree {
	int lazyV[1 << DEPTH + 1];
	int lazyT[1 << DEPTH + 1];	//null is -1
	int segMin[1 << DEPTH + 1];

	SegTree() {
		for (int i = 0; i < 1 << DEPTH + 1; i++) {
			lazyV[i] = 0;
			lazyT[i] = -1;
			segMin[i] = INTMAX;
		}
	};
	
	void lazy_evaluate(int id) {
		if (lazyT[id] == -1) return;
		
		segMin[id] = lazyV[id];
		
		if (id < (1 << DEPTH) - 1) {
			//if (lazyT[2 * id + 1] < lazyT[id]) {
				lazyT[2 * id + 1] = lazyT[id];
				lazyV[2 * id + 1] = lazyV[id];
			//}
			//if (lazyT[2 * id + 2] < lazyT[id]) {
				lazyT[2 * id + 2] = lazyT[id];
				lazyV[2 * id + 2] = lazyV[id];
			//}
		}
		
		lazyT[id] = -1;
	}
	
	//[l, r)
	void update(int l, int r, int x, int Time, int a = 0, int b = (1 <<DEPTH), int id = 0) {
		lazy_evaluate(id);
		
		if (a >= r || b <= l) return;
		if (l <= a && b <= r) {
			lazyT[id] = Time;
			lazyV[id] = x;
			lazy_evaluate(id);
			return;
		}
		
		update(l, r, x, Time, a, (a + b) / 2, id * 2 + 1);
		update(l, r, x, Time, (a + b) / 2, b, id * 2 + 2);
		segMin[id] = min(segMin[id * 2 + 1], segMin[id * 2 + 2]);
	}
	
	int find(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return INTMAX;
		
		lazy_evaluate(id);
		if (l <= a && b <= r) {
			return segMin[id];
		}
		
		int u = find(l, r, a, (a + b) / 2, id * 2 + 1);
		int v = find(l, r, (a + b) / 2, b, id * 2 + 2);
		return min(u, v);
	}
};

SegTree seg;

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