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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (1<<18)
#define INIT 9223372036854775807
#define INIT2 2147483647
long long a[(2 * N)];
long long laz[(2 * N)];
int l[(2 * N)];
int r[(2 * N)];

long long f1(long long x, long long y) {
	if (x != INIT)return x;
	return y;
}
long long f2(long long x, long long y) {
	if (x != INIT)return x;
	return y;
}
long long f3(long long x, long long y) {
	return min(x, y);
}


void init(void) {
	f(i, (2 * N)) {
		a[i] = INIT2;
		laz[i] = INIT;
	}
	l[1] = 0;
	r[1] = N;
	for (int i = 1; i < N; i++) {
		l[(2 * i)] = l[i];
		r[(2 * i)] = (l[i] + r[i]) / 2;
		l[(2 * i) + 1] = (l[i] + r[i]) / 2;
		r[(2 * i) + 1] = r[i];
	}
	return;
}



long long change(int ll, int rr, int k, long long x) {
	long long vl, vr;
	if ((rr <= l[k]) || (r[k] <= ll))return f2(laz[k], a[k]);
	if (laz[k] != INIT) {
		a[k] = f2(laz[k], a[k]);
		if (k < N) {
			laz[(2 * k)] = f1(laz[k], laz[(2 * k)]);
			laz[(2 * k) + 1] = f1(laz[k], laz[(2 * k) + 1]);
		}
		laz[k] = INIT;
	}
	if ((ll <= l[k]) && (r[k] <= rr)) {
		laz[k] = f1(x, laz[k]);
		return f2(laz[k], a[k]);
	}
	else {
		int mm = (l[k] + r[k]) / 2;
		if ((l[k] < rr) && (ll < mm)) {
			vl = change(ll, rr, 2 * k, x);
		}
		else vl = f2(laz[(2 * k)], a[(2 * k)]);

		if ((mm < rr) && (ll < r[k])) {
			vr = change(ll, rr, (2 * k) + 1, x);
		}
		else vr = f2(laz[(2 * k) + 1], a[(2 * k + 1)]);

		a[k] = f3(vl, vr);
		return f2(laz[k], a[k]);
	}
}


long long search(int ll, int rr, int k) {
	if (laz[k] != INIT) {
		a[k] = f2(laz[k], a[k]);
		if (k < N) {
			laz[(2 * k)] = f1(laz[k], laz[(2 * k)]);
			laz[(2 * k) + 1] = f1(laz[k], laz[(2 * k) + 1]);
		}
		laz[k] = INIT;
	}
	long long vl, vr;
	if (rr <= l[k] || r[k] <= ll)return INIT2;
	else if (ll <= l[k] && r[k] <= rr) return f2(laz[k], a[k]);
	else {
		vl = search(ll, rr, 2 * k);
		vr = search(ll, rr, (2 * k) + 1);
		a[k] = f3(f2(laz[(2 * k)], a[(2 * k)]), f2(laz[(2 * k) + 1], a[(2 * k) + 1]));
		return f3(vl, vr);
	}
}


int main(void) {
	int q;
	int c, x, y;
	long long k;
	init();
	scanf("%d %d", &c, &q);
	f(qq, q) {
		scanf("%d", &c);
		if (c == 0) {
			scanf("%d %d %lld", &x, &y, &k);
			change(x, y + 1, 1, k);
		}
		else if (c == 1) {
			scanf("%d %d", &x, &y);
			k = search(x, y + 1, 1);
			printf("%lld\n", k);
		}
	}
	return 0;
}